liquibase

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Liquibase package aims to provide a ox plugin to manage migrations with the Liquibase style. That is, using the databasechangelog and databasechangeloglock as well as the xml format for liquibase migrations.

IMPORTANT: This plugin is not ready to be used in production, rather it aims to allow developers to avoid the java and liquibase installation by doing what liquibase does.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameArgMissing = errors.New("name arg missing")
	ErrInvalidName    = errors.New("invalid migration name")
	ErrInvalidPath    = errors.New("invalid path")
)
View Source
var ErrInvalidInstruction = errors.New("Invalid instruction please specify up or down")

Functions

func Plugins added in v0.7.5

func Plugins(conns interface{}) []plugins.Plugin

Plugins on this package.

Types

type ChangeLog added in v0.7.11

type ChangeLog struct {
	XMLName    xml.Name        `xml:"databaseChangeLog"`
	Migrations []MigrationFile `xml:"include"`
}

DatabaseChangelog file containing all of the migrations. This is the root migrations commander, the tool only considers migration files in the changelog.

type ChangeSet added in v0.7.11

type ChangeSet struct {
	ID          string `xml:"id,attr"`
	Author      string `xml:"author,attr"`
	SQL         string `xml:"sql"`
	RollbackSQL string `xml:"rollback"`
}

ChangeSet with SQL and Rollback instructions.

func (ChangeSet) Execute added in v0.7.11

func (cs ChangeSet) Execute(conn *pgx.Conn, file string) error

Execute a changeset takes the SQL part of the changeset and runs it.

func (ChangeSet) Rollback added in v0.7.11

func (cs ChangeSet) Rollback(conn *pgx.Conn) error

Rollback the changeset runs the Rollback section of the changeset.

type Command

type Command struct {
	// contains filtered or unexported fields
}

func (Command) EnsureTables added in v0.7.11

func (lb Command) EnsureTables(conn *pgx.Conn) error

EnsureTables are in the database.

func (*Command) Flags added in v0.6.3

func (lb *Command) Flags() *pflag.FlagSet

func (Command) HelpText added in v0.5.2

func (lb Command) HelpText() string

func (Command) Name

func (lb Command) Name() string

func (Command) ParentName

func (lb Command) ParentName() string

func (*Command) ParseFlags added in v0.6.3

func (lb *Command) ParseFlags(args []string)

func (Command) ReadChangelog added in v0.7.11

func (lb Command) ReadChangelog() (*ChangeLog, error)

func (Command) ReadMigration added in v0.7.11

func (lb Command) ReadMigration(path string) (*Migration, error)

func (*Command) Rollback added in v0.7.11

func (lb *Command) Rollback() error

func (*Command) Run

func (lb *Command) Run(ctx context.Context, root string, args []string) error

func (*Command) RunBeforeTest

func (lb *Command) RunBeforeTest(ctx context.Context, root string, args []string) error

func (Command) Up added in v0.7.11

func (lb Command) Up() error

type Generator added in v0.7.0

type Generator struct {
	// contains filtered or unexported fields
}

Generator for liquibase SQL migrations, it generates xml liquibase for SQL in the root + basedir folder. It uses the argument passed to determine both the name of the migration and the destination. Some examples are: - "ox generate migration name" generates [timestamp]-name.xml - "ox generate migration folder/name" generates folder/[timestamp]-name.xml - "ox generate migration name --base migrations" generates migrations/[timestamp]-name.xml

func (*Generator) Flags added in v0.7.8

func (g *Generator) Flags() *pflag.FlagSet

Flags parsed by the plugin

func (Generator) Generate added in v0.7.0

func (g Generator) Generate(ctx context.Context, root string, args []string) error

Generate a new migration based on the passed args. This needs at least 3 args since the 3rd arg will be used by the generator to build the name of the migration.

func (Generator) Name added in v0.7.0

func (g Generator) Name() string

Name is the name used to identify the generator and also the plugin

func (*Generator) ParseFlags added in v0.7.8

func (g *Generator) ParseFlags(args []string)

Parseflags will parse the baseFolder from the --base or -b flag

type Migration added in v0.7.11

type Migration struct {
	ChangeSets []ChangeSet `xml:"changeSet"`
}

Migration xml with liquibase format. A migration may be composed of multiple changesets.

type MigrationFile added in v0.7.11

type MigrationFile struct {
	File string `xml:"file,attr"`
}

MigrationFiles in the changelog. These are used to get the file path to the migration.

type URLProvider added in v0.5.3

type URLProvider interface {
	URL() string
}

URLProvider provider is a struct that has the URL() method. Like pop.Connection.

Jump to

Keyboard shortcuts

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