Documentation
¶
Index ¶
- Constants
- func ExecStatements(ctx context.Context, tx bun.Tx, statements ...string) error
- type Logger
- type Migration
- type MigrationSet
- type Migrator
- func (m *Migrator) ListApplied(ctx context.Context, pluginID string) ([]schemaMigration, error)
- func (m *Migrator) Migrate(ctx context.Context, sets []MigrationSet) error
- func (m *Migrator) RollbackAll(ctx context.Context, sets []MigrationSet) error
- func (m *Migrator) RollbackLast(ctx context.Context, set MigrationSet) error
- type MigratorOption
- type ProviderVariants
Constants ¶
const CorePluginID = "core"
CorePluginID identifies the core migrations set.
const (
DefaultSchemaTable = "auth_schema_migrations"
)
DefaultSchemaTable is the shared table storing migration metadata.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface {
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
}
Logger is a minimal logging interface used by the migrator.
type Migration ¶
type Migration struct {
Version string
Up func(ctx context.Context, tx bun.Tx) error
Down func(ctx context.Context, tx bun.Tx) error
}
Migration represents a single schema change with reversible logic.
func ForProvider ¶
func ForProvider(provider string, variants ProviderVariants) []Migration
ForProvider returns the migrations for the requested provider using the supplied variants.
type MigrationSet ¶
MigrationSet groups migrations under a plugin identifier with optional dependencies.
func CoreMigrationSet ¶
func CoreMigrationSet(provider string) (MigrationSet, error)
CoreMigrationSet returns the programmatic migrations for the core schema.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator orchestrates plugin-aware migrations backed by Bun transactions.
func NewMigrator ¶
NewMigrator constructs a Migrator backed by the provided Bun database.
func (*Migrator) ListApplied ¶
ListApplied returns applied migrations for all plugins or a specific plugin when pluginID is provided.
func (*Migrator) Migrate ¶
func (m *Migrator) Migrate(ctx context.Context, sets []MigrationSet) error
Migrate applies all pending migrations respecting plugin dependencies.
func (*Migrator) RollbackAll ¶
func (m *Migrator) RollbackAll(ctx context.Context, sets []MigrationSet) error
RollbackAll executes Down migrations for the provided sets in reverse dependency order.
func (*Migrator) RollbackLast ¶
func (m *Migrator) RollbackLast(ctx context.Context, set MigrationSet) error
RollbackLast rolls back the most recent migration applied for a plugin in the provided set.
type MigratorOption ¶
type MigratorOption func(*Migrator)
MigratorOption configures optional Migrator behavior.
type ProviderVariants ¶
ProviderVariants maps a database provider to a lazy migration constructor.