Documentation
¶
Overview ¶
Package migrate installs and removes the Foreman schema with embedded, transactional SQL migrations.
Index ¶
- Variables
- func Down(ctx context.Context, db DB, opts ...Option) error
- func Latest() int
- func SQL(up bool, opts ...Option) (string, error)
- func Up(ctx context.Context, db DB, opts ...Option) error
- func Version(ctx context.Context, db DB, opts ...Option) (int, error)
- type DB
- type Migration
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownVersion = errors.New("migrate: database has a version this binary does not know")
ErrUnknownVersion reports a database migrated by a newer Foreman.
Functions ¶
func Down ¶
Down reverts migrations newest first down to the target version (0 by default, which removes every Foreman object but keeps the schema).
func SQL ¶
SQL returns the statements Up (up=true) or Down would run on an empty (or fully migrated) database, for users who apply migrations with their own tools. The migrations table is included.
Types ¶
type Migration ¶
Migration is one embedded schema version.
func Migrations ¶
Migrations returns the embedded migrations in version order.
type Option ¶
type Option func(*options)
Option configures a migration run.
func WithSchema ¶
WithSchema installs Foreman into schema instead of public.
func WithTargetVersion ¶
WithTargetVersion stops Down at version v instead of removing everything.