Documentation
¶
Overview ¶
Package migrations provides a file-based migration engine for GORM.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(m Migration)
Register adds a migration to the global registry. Called from migration files (typically in init()).
func ResetRegistry ¶
func ResetRegistry()
ResetRegistry clears all registered migrations. Used in tests only.
Types ¶
type Migration ¶
type Migration struct {
Version string
Up MigrationFunc
Down MigrationFunc
}
Migration represents a single migration with up and down functions.
type MigrationFunc ¶
MigrationFunc is a function that performs a migration step.
type MigrationStatus ¶
MigrationStatus represents the status of a single migration.
type Migrator ¶
Migrator manages database migrations.
func NewMigrator ¶
NewMigrator creates a Migrator and ensures the schema_migrations table exists.
func (*Migrator) Rollback ¶
Rollback undoes the last batch of applied migrations. Returns the number of migrations rolled back.
func (*Migrator) Run ¶
Run applies all pending migrations in version order. Returns the number of migrations applied.
func (*Migrator) Status ¶
func (m *Migrator) Status() ([]MigrationStatus, error)
Status returns the status of all registered migrations.