Documentation ¶
Index ¶
- Variables
- func AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error)
- func AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.Tx) error)
- func Create(db *sql.DB, dir, name, migrationType string, sequential bool) error
- func CreateMigration(name, migrationType, dir string, version string) (path string, err error)
- func Down(db *sql.DB, dir string) error
- func DownTo(db *sql.DB, dir string, version int64) error
- func EnsureDBVersion(db *sql.DB) (int64, error)
- func FinalizeMigration(tx *sql.Tx, direction bool, v int64) error
- func GetDBVersion(db *sql.DB) (int64, error)
- func LoadMigrationPlugins(dirpath string) error
- func NumericComponent(name string) (int64, error)
- func Redo(db *sql.DB, dir string) error
- func Run(command string, db *sql.DB, dir string, args ...string) error
- func SetDialect(d string) error
- func Status(db *sql.DB, dir string) error
- func Up(db *sql.DB, dir string) error
- func UpByOne(db *sql.DB, dir string) error
- func UpTo(db *sql.DB, dir string, version int64) error
- func Version(db *sql.DB, dir string) error
- 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 PostgresDialect
- type SqlDialect
- type Sqlite3Dialect
- type TemplateParams
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddNamedMigration ¶
func CreateMigration ¶
func EnsureDBVersion ¶
retrieve the current version for this DB. Create and initialize the DB version table if it doesn't exist.
func FinalizeMigration ¶
Update the version table for the given migration, and finalize the transaction.
func GetDBVersion ¶
wrapper for EnsureDBVersion for callers that don't already have their own DB instance
func LoadMigrationPlugins ¶
LoadMigrationPlugins loads all the valid looking precompiled migration libraries in the migrations folder and go func registry, and key them by version. Registration is done automatically by shared library init func.
func NumericComponent ¶
look 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 SetDialect ¶
Types ¶
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 UpFn func(*sql.Tx) error // Up go migration function DownFn func(*sql.Tx) error // Down go migration function }
func LastMigration ¶
lastVersion returns version of last migration present in dirpath
type MigrationRecord ¶
type Migrations ¶
type Migrations []*Migration
func CollectMigrations ¶
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 (Migrations) Last ¶
func (ms Migrations) Last() (*Migration, error)
func (Migrations) Less ¶
func (ms Migrations) Less(i, j int) bool
func (Migrations) String ¶
func (ms Migrations) String() string
func (Migrations) Swap ¶
func (ms Migrations) Swap(i, j int)
type MySqlDialect ¶
type MySqlDialect struct{}
type PostgresDialect ¶
type PostgresDialect struct{}
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 GetDialect ¶
func GetDialect() SqlDialect
type Sqlite3Dialect ¶
type Sqlite3Dialect struct{}
type TemplateParams ¶
type TemplateParams struct {
Version, Name string
}