liquo

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 20 Imported by: 0

README

Liquo

Liquo is an experimental Liquibase plugin for oxpecker. It's aimed to make the development of Buffalo apps with Liquibase migrations a bit more easy but avoiding the installation of Java tools for the development workflow.

Installation

Liquo is provided as a library you can pull it with

go get github.com/wawandco/liquo

An then in your cmd/ox/main.go use it by appending it to the CLi plugins.

...
cl.Plugins = append(cl.Plugins, liquo.Plugins()...)
...

Limited Functionallity

Liquo still experimental, it does not provide the same amount of statements, formats or databases that liquibase supports.

Liquo ONLY supports:

  • PostgresSQL Database
  • Liquibase XML format, only the following statements:
    • sql
    • rollback

While is possible to add the rest of statements this is where the tool is at the moment.

License

Liquo is released under the MIT License.

Documentation

Overview

Liquo 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")
	ErrInvalidChangelogFormat = errors.New("changelog.xml file has bad format or is empty")
)
View Source
var ErrInvalidInstruction = errors.New("Invalid instruction please specify up or down")

Functions

func Plugins

func Plugins() []core.Plugin

Plugins on this package.

Types

type ChangeLog

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

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

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

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

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

EnsureTables are in the database.

func (*Command) Flags

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

func (Command) HelpText

func (lb Command) HelpText() string

func (Command) Name

func (lb Command) Name() string

func (Command) ParentName

func (lb Command) ParentName() string

func (*Command) ParseFlags

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

func (Command) ReadChangelog

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

func (Command) ReadMigration

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

func (*Command) Rollback

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

func (lb Command) Up() error

type Generator

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

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

Flags parsed by the plugin

func (Generator) Generate

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) InvocationName

func (g Generator) InvocationName() string

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

func (Generator) Name

func (g Generator) Name() string

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

func (*Generator) ParseFlags

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

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

type Migration

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

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

type MigrationFile

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

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

Directories

Path Synopsis
internal
log
package log aims to provide common logging interface for the CLI.
package log aims to provide common logging interface for the CLI.

Jump to

Keyboard shortcuts

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