Documentation ¶
Index ¶
- Constants
- Variables
- func NumericComponent(name string) (int64, error)
- func OpenDBWithDriver(driver string, dbstring string) (*sql.DB, error)
- func SetLogger(l Logger)
- func SetSequential(s bool)
- func SetTableName(n string)
- func SetVerbose(v bool)
- func TableName() string
- type ClickHouseDialect
- type Instance
- func (in *Instance) AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error)
- func (in *Instance) AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.Tx) error)
- func (in *Instance) CollectMigrations(dirpath string, current, target int64) (Migrations, error)
- func (in *Instance) Create(db *sql.DB, dir, name, migrationType string) error
- func (in *Instance) CreateWithTemplate(db *sql.DB, dir string, tmpl *template.Template, name, migrationType string) error
- func (in *Instance) Down(db *sql.DB, dir string, opts ...OptionsFunc) error
- func (in *Instance) DownTo(db *sql.DB, dir string, version int64, opts ...OptionsFunc) error
- func (in *Instance) EnsureDBVersion(db *sql.DB) (int64, error)
- func (in *Instance) Fix(dir string) error
- func (in *Instance) GetDBVersion(db *sql.DB) (int64, error)
- func (in *Instance) GetDialect() SQLDialect
- func (in *Instance) Redo(db *sql.DB, dir string, opts ...OptionsFunc) error
- func (in *Instance) Reset(db *sql.DB, dir string, opts ...OptionsFunc) error
- func (in *Instance) Run(command string, db *sql.DB, dir string, args ...string) error
- func (in *Instance) RunWithOptions(command string, db *sql.DB, dir string, args []string, options ...OptionsFunc) error
- func (in *Instance) SetBaseFS(fsys fs.FS)
- func (in *Instance) Status(db *sql.DB, dir string, opts ...OptionsFunc) error
- func (in *Instance) Up(db *sql.DB, dir string, opts ...OptionsFunc) error
- func (in *Instance) UpByOne(db *sql.DB, dir string, opts ...OptionsFunc) error
- func (in *Instance) UpTo(db *sql.DB, dir string, version int64, opts ...OptionsFunc) error
- func (in *Instance) Version(db *sql.DB, dir string, opts ...OptionsFunc) error
- type Logger
- type Migration
- type MigrationRecord
- type Migrations
- func (ms Migrations) Current(current int64) (*Migration, error)
- func (ms Migrations) Last() (*Migration, error)
- func (ms Migrations) Len() int
- func (ms Migrations) Less(i, j int) bool
- func (ms Migrations) Next(current int64) (*Migration, error)
- func (ms Migrations) Previous(current int64) (*Migration, error)
- func (ms Migrations) String() string
- func (ms Migrations) Swap(i, j int)
- type MySQLDialect
- type OptionsFunc
- type PostgresDialect
- type RedshiftDialect
- type SQLDialect
- type SqlServerDialect
- type Sqlite3Dialect
- type TiDBDialect
Constants ¶
const VERSION = "v3.2.0"
Deprecated: VERSION will no longer be supported in v4.
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) )
Functions ¶
func NumericComponent ¶
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 OpenDBWithDriver ¶
OpenDBWithDriver creates a connection to a database, and modifies goose internals to be compatible with the supplied driver by calling SetDialect.
func SetSequential ¶ added in v3.5.1
func SetSequential(s bool)
SetSequential set whether to use sequential versioning instead of timestamp based versioning
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func NewInstance ¶
func NewInstance(dialect SQLDialect) *Instance
func (*Instance) AddMigration ¶
AddMigration adds a migration.
func (*Instance) AddNamedMigration ¶
func (in *Instance) AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.Tx) error)
AddNamedMigration : Add a named migration.
func (*Instance) CollectMigrations ¶
func (in *Instance) 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 (*Instance) CreateWithTemplate ¶ added in v3.5.1
func (in *Instance) CreateWithTemplate(db *sql.DB, dir string, tmpl *template.Template, name, migrationType string) error
Create writes a new blank migration file.
func (*Instance) EnsureDBVersion ¶ added in v3.5.1
EnsureDBVersion retrieves the current version for this DB. Create and initialize the DB version table if it doesn't exist.
func (*Instance) GetDBVersion ¶ added in v3.5.1
GetDBVersion is an alias for EnsureDBVersion, but returns -1 in error.
func (*Instance) GetDialect ¶ added in v3.5.1
func (in *Instance) GetDialect() SQLDialect
GetDialect gets the SQLDialect
func (*Instance) RunWithOptions ¶ added in v3.5.1
func (in *Instance) RunWithOptions(command string, db *sql.DB, dir string, args []string, options ...OptionsFunc) error
Run runs a goose command with options.
func (*Instance) SetBaseFS ¶ added in v3.5.1
SetBaseFS sets a base FS to discover migrations. It can be used with 'embed' package. Calling with 'nil' argument leads to default behaviour: discovering migrations from os filesystem. Note that modifying operations like Create will use os filesystem anyway.
type Logger ¶
type Logger interface { Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Print(v ...interface{}) Println(v ...interface{}) Printf(format string, v ...interface{}) }
Logger is standard logger interface
type Migration ¶
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 or go file Registered bool UpFn func(*sql.Tx) error // Up go migration function DownFn func(*sql.Tx) error // Down go migration function // contains filtered or unexported fields }
Migration struct.
func (*Migration) GetDialect ¶ added in v3.5.1
func (m *Migration) GetDialect() SQLDialect
type MigrationRecord ¶
type MigrationRecord struct { VersionID int64 TStamp time.Time IsApplied bool // was this a result of up() or down() }
MigrationRecord struct.
type Migrations ¶
type Migrations []*Migration
Migrations slice.
func (Migrations) Current ¶
func (ms Migrations) Current(current int64) (*Migration, error)
Current gets the current migration.
func (Migrations) Last ¶
func (ms Migrations) Last() (*Migration, error)
Last gets the last migration.
func (Migrations) Less ¶
func (ms Migrations) Less(i, j int) bool
func (Migrations) Next ¶
func (ms Migrations) Next(current int64) (*Migration, error)
Next gets the next migration.
func (Migrations) Previous ¶
func (ms Migrations) Previous(current int64) (*Migration, error)
Previous : Get the previous migration.
func (Migrations) String ¶
func (ms Migrations) String() string
func (Migrations) Swap ¶
func (ms Migrations) Swap(i, j int)
type OptionsFunc ¶ added in v3.5.1
type OptionsFunc func(o *options)
func WithAllowMissing ¶ added in v3.5.1
func WithAllowMissing() OptionsFunc
func WithNoVersioning ¶ added in v3.5.1
func WithNoVersioning() OptionsFunc
type SQLDialect ¶
type SQLDialect interface {
// contains filtered or unexported methods
}
SQLDialect abstracts the details of specific SQL dialects for goose's few SQL specific statements
func ParseDialect ¶ added in v3.5.1
func ParseDialect(d string) (SQLDialect, error)
ParseDialect returns a SQLDialect