goose: github.com/grailbio-external/goose Index | Files

package goose

import "github.com/grailbio-external/goose"

Index

Package Files

create.go dialect.go down.go fix.go goose.go log.go migrate.go migration.go migration_sql.go redo.go reset.go status.go up.go version.go

Variables

var (
    // ErrNoCurrentVersion when a current migration version is not found.
    ErrNoCurrentVersion = errors.New("no current version found")
    // ErrNoNextVersion when the next migration version is not found.
    ErrNoNextVersion = errors.New("no next version found")
    // MaxVersion is the maximum allowed version.
    MaxVersion int64 = 9223372036854775807 // max(int64)

)

func AddMigration Uses

func AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error)

AddMigration adds a migration.

func AddNamedMigration Uses

func AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.Tx) error)

AddNamedMigration : Add a named migration.

func Create Uses

func Create(db *sql.DB, dir, name, migrationType string) error

Create writes a new blank migration file.

func CreateWithTemplate Uses

func CreateWithTemplate(db *sql.DB, dir string, migrationTemplate *template.Template, name, migrationType string) error

Create writes a new blank migration file.

func Down Uses

func Down(db *sql.DB, dir string) error

Down rolls back a single migration from the current version.

func DownTo Uses

func DownTo(db *sql.DB, dir string, version int64) error

DownTo rolls back migrations to a specific version.

func EnsureDBVersion Uses

func EnsureDBVersion(db *sql.DB) (int64, error)

EnsureDBVersion retrieves the current version for this DB. Create and initialize the DB version table if it doesn't exist.

func Fix Uses

func Fix(dir string) error

func GetDBVersion Uses

func GetDBVersion(db *sql.DB) (int64, error)

GetDBVersion is an alias for EnsureDBVersion, but returns -1 in error.

func NumericComponent Uses

func NumericComponent(name string) (int64, error)

NumericComponent looks for migration scripts with names in the form: XXX_descriptivename.ext where XXX specifies the version number and ext specifies the type of migration

func Redo Uses

func Redo(db *sql.DB, dir string) error

Redo rolls back the most recently applied migration, then runs it again.

func Reset Uses

func Reset(db *sql.DB, dir string) error

Reset rolls back all migrations

func Run Uses

func Run(command string, db *sql.DB, dir string, unappliedOnly bool, includeMissing bool, dryRun bool, args ...string) error

Run runs a goose command.

func SetDialect Uses

func SetDialect(d string) error

SetDialect sets the SQLDialect

func SetLogger Uses

func SetLogger(l Logger)

SetLogger sets the logger for package output

func SetTableName Uses

func SetTableName(n string)

SetTableName set goose db version table name

func Status Uses

func Status(db *sql.DB, dir string) error

Status prints the status of all migrations.

func StatusUnapplied Uses

func StatusUnapplied(db *sql.DB, dir string) error

StatusUnapplied prints all unapplied migrations

func TableName Uses

func TableName() string

TableName returns goose db version table name

func Up Uses

func Up(db *sql.DB, dir string, includeMissing bool, onlyOne bool, endVersion *int64, dryRun bool) error

Up performs all types of migrations upwards, depending on the params.

func Version Uses

func Version(db *sql.DB, dir string) error

Version prints the current version of the database.

type Logger Uses

type Logger interface {
    Fatal(v ...interface{})
    Fatalf(format string, v ...interface{})
    Print(v ...interface{})
    Println(v ...interface{})
    Printf(format string, v ...interface{})
}

Logger is standart logger interface

type Migration Uses

type Migration struct {
    Version    int64
    Next       int64  // next version, or -1 if none
    Previous   int64  // previous version, -1 if none
    Source     string // path to .sql script
    Registered bool
    UpFn       func(*sql.Tx) error // Up go migration function
    DownFn     func(*sql.Tx) error // Down go migration function
}

Migration struct.

func (*Migration) Down Uses

func (m *Migration) Down(db *sql.DB) error

Down runs a down migration.

func (*Migration) String Uses

func (m *Migration) String() string

func (*Migration) Up Uses

func (m *Migration) Up(db *sql.DB) error

Up runs an up migration.

type MigrationRecord Uses

type MigrationRecord struct {
    VersionID int64
    TStamp    time.Time
    IsApplied bool // was this a result of up() or down()
}

MigrationRecord struct.

type Migrations Uses

type Migrations []*Migration

Migrations slice.

func CollectMigrations Uses

func CollectMigrations(dirpath string, current, target int64) (Migrations, error)

CollectMigrations returns all the valid looking migration scripts in the migrations folder and go func registry, and key them by version.

func CollectUnappliedMigrations Uses

func CollectUnappliedMigrations(db *sql.DB, dir string) (unappliedMigrations Migrations, err error)

CollectUnappliedMigrations returns all unapplied migrations.

func (Migrations) Current Uses

func (ms Migrations) Current(current int64) (*Migration, error)

Current gets the current migration.

func (Migrations) Last Uses

func (ms Migrations) Last() (*Migration, error)

Last gets the last migration.

func (Migrations) Len Uses

func (ms Migrations) Len() int

helpers so we can use pkg sort

func (Migrations) Less Uses

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

func (Migrations) Next Uses

func (ms Migrations) Next(current int64) (*Migration, error)

Next gets the next migration.

func (Migrations) Previous Uses

func (ms Migrations) Previous(current int64) (*Migration, error)

Previous : Get the previous migration.

func (Migrations) String Uses

func (ms Migrations) String() string

func (Migrations) Swap Uses

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

type MySQLDialect Uses

type MySQLDialect struct{}

MySQLDialect struct.

type PostgresDialect Uses

type PostgresDialect struct{}

PostgresDialect struct.

type RedshiftDialect Uses

type RedshiftDialect struct{}

RedshiftDialect struct.

type SQLDialect Uses

type SQLDialect interface {
    // contains filtered or unexported methods
}

SQLDialect abstracts the details of specific SQL dialects for goose's few SQL specific statements

func GetDialect Uses

func GetDialect() SQLDialect

GetDialect gets the SQLDialect

type Sqlite3Dialect Uses

type Sqlite3Dialect struct{}

Sqlite3Dialect struct.

type TiDBDialect Uses

type TiDBDialect struct{}

TiDBDialect struct.

Package goose imports 16 packages (graph). Updated 2020-07-10. Refresh now. Tools for package owners.