Documentation
¶
Overview ¶
Package migrate provides a minimal database schema migration runner.
Index ¶
Constants ¶
View Source
const (
// DefaultTableName is the table used to track applied migrations.
DefaultTableName = "rain_schema_migrations"
)
Variables ¶
View Source
var ( // ErrDuplicateMigrationID is returned when the same migration ID appears more than once. ErrDuplicateMigrationID = errors.New("migrate: duplicate migration id") // ErrEmptyMigrationID is returned when a migration ID is blank. ErrEmptyMigrationID = errors.New("migrate: migration id is required") // ErrNilMigrationUp is returned when a migration has a nil Up function. ErrNilMigrationUp = errors.New("migrate: migration up function is required") )
Functions ¶
This section is empty.
Types ¶
type ApplyResult ¶
type ApplyResult struct {
AppliedIDs []string
}
ApplyResult summarizes one ApplyPending run.
func ApplyPending ¶
ApplyPending applies pending migrations using the default migration table.
type Migration ¶
type Migration struct {
ID string
// Up is the forward migration function.
Up Operation
// Down is reserved for future rollback support.
// v1 runner behavior is forward-only.
Down Operation
// NonTransactional disables the per-migration transaction wrapper.
NonTransactional bool
}
Migration defines one ordered schema change.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner applies migrations and tracks their state in a schema table.
func (*Runner) ApplyPending ¶
func (r *Runner) ApplyPending(ctx context.Context, db *sql.DB, migrations []Migration) (ApplyResult, error)
ApplyPending applies migrations that are not yet recorded in the migration table.
Click to show internal directories.
Click to hide internal directories.