Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrate ¶
func Migrate(ctx context.Context, db adapter.DatabaseConn, opts MigrationOptions, logger *slog.Logger) (err error)
Migrate performs database migrations.
Types ¶
type MigrationFn ¶
type MigrationOptions ¶
type MigrationOptions struct {
// List of migrations to execute.
// Each item is a function that receives a context and the database connection, and can execute queries.
Migrations []MigrationFn
// EnsureMetadataTable ensures that the metadata table exists.
EnsureMetadataTable func(ctx context.Context) error
// GetVersionQuery is the query to execute to load the latest migration version.
GetVersionQuery string
// UpdateVersionQuery is a function that returns the query to update the migration version, and the arg.
UpdateVersionQuery func(version string) (string, any)
}
MigrationOptions contains options for the Migrate function.
type MigrationTeardownFn ¶
type MigrationTeardownFn = func() error
Click to show internal directories.
Click to hide internal directories.