fizzx

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSchemaMigrations added in v0.0.38

func CreateSchemaMigrations(c *pop.Connection) error

CreateSchemaMigrations sets up a table to track migrations. This is an idempotent operation.

func MigrationContent added in v0.0.38

func MigrationContent(mf Migration, c *pop.Connection, r io.Reader, usingTemplate bool) ([]string, error)

Types

type DumpMigrator

type DumpMigrator struct {
	Migrator
	Path string
}

func NewDumpMigrator

func NewDumpMigrator(path string, dest string, shouldReplace, dumpSchema bool, c *pop.Connection, l *logrusx.Logger) (DumpMigrator, error)

type Migration added in v0.0.38

type Migration struct {
	// Path to the migration (./migrations/123_create_widgets.up.sql)
	Path string
	// Version of the migration (123)
	Version string
	// Name of the migration (create_widgets)
	Name string
	// Direction of the migration (up)
	Direction string
	// Type of migration (sql)
	Type string
	// DB type (all|postgres|mysql...)
	DBType string
	// Runner function to run/execute the migration
	Runner func(mf Migration) ([]MigrationTuple, error)
}

Migration handles the data for a given database migration

func (Migration) Run added in v0.0.38

func (mf Migration) Run() ([]MigrationTuple, error)

Run the migration. Returns an error if there is no mf.Runner defined.

type MigrationTuple added in v0.0.38

type MigrationTuple struct {
	ID        string
	Statement string
}

type Migrations added in v0.0.38

type Migrations []Migration

Migrations is a collection of Migration

func (*Migrations) Filter added in v0.0.38

func (mfs *Migrations) Filter(f func(mf Migration) bool)

func (Migrations) Len added in v0.0.38

func (mfs Migrations) Len() int

func (Migrations) Less added in v0.0.38

func (mfs Migrations) Less(i, j int) bool

func (Migrations) Swap added in v0.0.38

func (mfs Migrations) Swap(i, j int)

type Migrator added in v0.0.38

type Migrator struct {
	Connection *pop.Connection
	SchemaPath string
	Migrations map[string]Migrations
	// contains filtered or unexported fields
}

Migrator forms the basis of all migrations systems. It does the actual heavy lifting of running migrations. When building a new migration system, you should embed this type into your migrator.

func NewMigrator added in v0.0.38

func NewMigrator(c *pop.Connection, l *logrusx.Logger) Migrator

NewMigrator returns a new "blank" migrator. It is recommended to use something like MigrationBox or FileMigrator. A "blank" Migrator should only be used as the basis for a new type of migration system.

func (Migrator) CreateSchemaMigrations added in v0.0.38

func (m Migrator) CreateSchemaMigrations() error

CreateSchemaMigrations sets up a table to track migrations. This is an idempotent operation.

func (Migrator) Down added in v0.0.38

func (m Migrator) Down(step int) error

Down runs pending "down" migrations and rolls back the database by the specified number of steps.

func (Migrator) DumpMigrationSchema added in v0.0.38

func (m Migrator) DumpMigrationSchema() error

DumpMigrationSchema will generate a file of the current database schema based on the value of Migrator.SchemaPath

func (Migrator) Reset added in v0.0.38

func (m Migrator) Reset() error

Reset the database by running the down migrations followed by the up migrations.

func (Migrator) Status added in v0.0.38

func (m Migrator) Status(out io.Writer) error

Status prints out the status of applied/pending migrations.

func (Migrator) Up added in v0.0.38

func (m Migrator) Up() error

Up runs pending "up" migrations and applies them to the database.

func (Migrator) UpTo added in v0.0.38

func (m Migrator) UpTo(step int) (applied int, err error)

UpTo runs up to step "up" migrations and applies them to the database. If step <= 0 all pending migrations are run.

Jump to

Keyboard shortcuts

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