Documentation
¶
Overview ¶
Package migrate provides dialect-aware, transactional SQL migrations on top of database/sql.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleCommand ¶
func HandleCommand( ctx context.Context, args []string, runner *Runner, migrations []Migration, output io.Writer, ) (handled bool, err error)
HandleCommand executes a migration command from application arguments.
Supported commands are migrate, migrate:rollback, and migrate:status. It returns handled=false for arguments that belong to another application command.
Types ¶
type AppliedMigration ¶
AppliedMigration is a migration recorded in the database.
type Dialect ¶
type Dialect struct {
// contains filtered or unexported fields
}
Dialect describes the small amount of SQL syntax required by the migration metadata table.
func DialectForDriver ¶
DialectForDriver maps common database/sql driver names to a migration dialect.
type Migration ¶
Migration is one ordered database schema change.
func LoadFS ¶
LoadFS loads paired .up.sql and .down.sql migrations from directory.
File names use VERSION_NAME.up.sql and VERSION_NAME.down.sql. Multiple SQL statements are separated by a line containing "-- kora:split".
func ValidateMigrations ¶
ValidateMigrations validates and sorts migrations by ascending version.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner applies migrations through a database/sql pool.
func (*Runner) Down ¶
func (r *Runner) Down(ctx context.Context, migrations []Migration, steps int) (count int, err error)
Down rolls back the most recently applied migrations.