Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBadFilenameFormat is returned if a migration file does not conform // with the expected name patter. Ex: 001_my-migration_up.sql ErrBadFilenameFormat = errors.New("bad-filename-format") // ErrInvalidDirection is returned if the direction of a migration is other // than 'up' or 'down' ErrInvalidDirection = errors.New("invalid-migration-direction") // ErrDBNotSupported is returned when trying to create a migrator instance // for an unsupported database. ErrDBNotSupported = errors.New("database-not-supported") )
View Source
var ( ErrCreatingTable = errors.New("error-creating-migration-table") ErrMigrationFailed = errors.New("migration-failed") ErrRegisteringMigration = errors.New("error-registering-migration") ErrGettingMigrations = errors.New("error-getting-migrations") ErrRollbackFailed = errors.New("error-rolling-back-migrations") ErrUpdatingMigration = errors.New("error-updating-migration-metadata") )
Functions ¶
func NewPostgres ¶
Types ¶
type AssetDirFunc ¶
type Migration ¶
type Migration struct {
ID string
Name string
Filename string `db:"filename"`
Up string
Down string
Status string
CreatedAt time.Time `db:"created_at"`
}
Migration represents an actual migration file.
type Migrator ¶
type Migrator interface {
// Init initializes migrations table in the given database.
Init() error
// Migrate runs a migration from an embedded asset. Go-bindata is the only
// library supported.
MigrateFromAsset(assetFunc AssetFunc, assetDirFunc AssetDirFunc) error
// Rollback reverts the last migration.
Rollback() error
// RollbackN reverts the last N migrations.
RollbackN(n uint) error
// Migrations returns the list of migrations currently applied to the database.
Migrations() ([]*Migration, error)
}
Click to show internal directories.
Click to hide internal directories.