Documentation
¶
Index ¶
- Constants
- Variables
- type ErrNameNotUnique
- type ErrorPair
- type Migration
- type Schema
- func (sch *Schema) Apply(migrations []Migration) (n int, err error)
- func (sch *Schema) ApplyEach(migrations []Migration) (n int, err error)
- func (sch *Schema) FindOne(migrations []Migration, name string) (res []Migration, err error)
- func (sch *Schema) FindUnapplied(migrations []Migration) (res []Migration, err error)
- func (sch *Schema) FindUnrolled(migrations []Migration) (res []Migration, err error)
- func (sch *Schema) Init() error
- func (sch *Schema) Rollback(migrations []Migration) (n int, err error)
- func (sch *Schema) RollbackEach(migrations []Migration) (n int, err error)
- type Struct
Constants ¶
const DefaultMigrationTableName = "schema_migrations"
DefaultMigrationTableName is the default migrations table name.
const DefaultSchemaName = "public"
DefaultSchemaName is the default schema name.
Variables ¶
var ErrMigrationNotFound = errors.New("migration not found")
ErrMigrationNotFound is returned by FindOne when migration is not found by name.
Functions ¶
This section is empty.
Types ¶
type ErrNameNotUnique ¶
type ErrNameNotUnique struct {
Name string
}
ErrNameNotUnique is returned whenever a non-unique migration name is found.
func (ErrNameNotUnique) Error ¶
func (err ErrNameNotUnique) Error() string
Error implements the error interface for ErrNameNotUnique.
type Migration ¶
Migration is a migration interface. A migration can apply itself, rollback itself and has a unique name.
func FindByName ¶
FindByName finds a migration by name.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the single database's schema representation.
func (*Schema) Apply ¶
Apply applies all migrations in a single transaction. It returns the number of applied migrations and error if any.
func (*Schema) ApplyEach ¶
ApplyEach applies each migration in a separate transaction. It returns the number of applied migrations and error if any.
func (*Schema) FindUnapplied ¶
FindUnapplied finds unapplied migrations.
func (*Schema) FindUnrolled ¶
FindUnrolled finds migrations that were not rolled back.