astipatch

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2021 License: MIT Imports: 10 Imported by: 0

README

Patch manager written in GO.

Languages

SQL

Patches are described as an array of transactions in yaml. Each transaction can contain multiple queries and/or rollbacks.

A transaction must only describe:

-
  queries:
    - >      
      CREATE TABLE test (
        name VARCHAR(255) NOT NULL
      )
  rollbacks:
    - DROP TABLE test
-
  queries:
    - INSERT INTO test (name) VALUES ('test 1'), ('test2')
    - UPDATE test SET name = 'test 2' WHERE id = 2
  rollbacks:
    - DELETE FROM test WHERE id IN (1, 2)
-
  queries:
    - ALTER TABLE test ADD id int NOT NULL AUTO_INCREMENT PRIMARY KEY
  rollbacks:
    - ALTER TABLE test DROP COLUMN id

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PatchesDirectoryPath = flag.String("astipatch-patches-directory-path", "", "the patches directory path")
)

Flags

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	PatchesDirectoryPath string `toml:"patches_directory_path"`
}

Configuration represents the patcher configuration

func FlagConfig

func FlagConfig() Configuration

FlagConfig generates a Configuration based on flags

type PatchSQL added in v0.5.0

type PatchSQL []PatchSQLTransaction

type PatchSQLTransaction added in v0.5.0

type PatchSQLTransaction struct {
	Queries   []string `yaml:"queries"`
	Rollbacks []string `yaml:"rollbacks"`
}

type Patcher

type Patcher interface {
	Init() error
	Load(c Configuration) error
	Patch() error
	Rollback() error
}

Patcher represents an object capable of patching

func NewPatcherSQL

func NewPatcherSQL(conn *sqlx.DB, s Storer, l astikit.StdLogger) Patcher

NewPatcherSQL creates a new SQL patcher

type Storer

type Storer interface {
	DeleteLastBatch() error
	Delta([]string) ([]string, error)
	Init() error
	InsertBatch([]string) error
	LastBatch() ([]string, error)
}

Storer represents an object capable of storing patch's state

func NewStorerSQL

func NewStorerSQL(conn *sqlx.DB) Storer

NewStorerSQL creates a new SQL storer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL