Documentation
¶
Index ¶
- func AddMigrationContext(up, down MigrationContext)
- func AddNamedMigrationContext(source string, up, down MigrationContext)
- func Create(dir, name string) error
- func ResetRegisteredMigrations()
- type Migrate
- func (m *Migrate) Create(name string) error
- func (m *Migrate) Down() error
- func (m *Migrate) DownContext(ctx context.Context) error
- func (m *Migrate) DownTo(version int64) error
- func (m *Migrate) DownToContext(ctx context.Context, version int64) error
- func (m *Migrate) Reset() error
- func (m *Migrate) ResetContext(ctx context.Context) error
- func (m *Migrate) Status() error
- func (m *Migrate) StatusContext(ctx context.Context) error
- func (m *Migrate) Up() error
- func (m *Migrate) UpContext(ctx context.Context) error
- func (m *Migrate) UpTo(version int64) error
- func (m *Migrate) UpToContext(ctx context.Context, version int64) error
- type Migration
- type MigrationContext
- type Option
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMigrationContext ¶
func AddMigrationContext(up, down MigrationContext)
AddMigrationContext adds Go migrations to the default registry.
func AddNamedMigrationContext ¶
func AddNamedMigrationContext(source string, up, down MigrationContext)
AddNamedMigrationContext adds named Go migrations to the default registry.
func ResetRegisteredMigrations ¶ added in v0.4.1
func ResetRegisteredMigrations()
ResetRegisteredMigrations clears the default global registry of migrations. This is primarily intended for tests to avoid cross-test interference.
Types ¶
type Migrate ¶
type Migrate struct {
// contains filtered or unexported fields
}
Migrate handles database migrations.
func (*Migrate) Create ¶
Create creates a new migration file with the given name in the specified directory.
func (*Migrate) DownContext ¶
DownContext rolls back the last migration.
func (*Migrate) DownToContext ¶
DownToContext rolls back the migrations to the specified version.
func (*Migrate) ResetContext ¶
ResetContext rolls back all migrations.
func (*Migrate) StatusContext ¶
StatusContext returns the status of the migrations.
type MigrationContext ¶
MigrationContext is a Go migration func that is run within a transaction and receives a context.
type Option ¶
type Option func(*Migrate)
func WithDryRun ¶ added in v0.4.0
WithDryRun enables or disables dry-run mode.
func WithMigrationDir ¶
WithMigrationDir sets the directory for the migration files.
func WithRegistry ¶ added in v0.4.1
WithRegistry sets the migration registry for the migrator.
func WithTableName ¶
WithTableName sets the table name for the migration.
type Registry ¶ added in v0.4.1
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶ added in v0.4.1
func NewRegistry() *Registry
NewRegistry creates an isolated migration registry.
func (*Registry) AddMigrationContext ¶ added in v0.4.1
func (r *Registry) AddMigrationContext(up, down MigrationContext)
AddMigrationContext adds Go migrations to the registry.
func (*Registry) AddNamedMigrationContext ¶ added in v0.4.1
func (r *Registry) AddNamedMigrationContext(source string, up, down MigrationContext) error
AddNamedMigrationContext adds named Go migrations to the registry.