Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultOptions can be used if you don't want to think about options. DefaultOptions = &Options{ TableName: "migrations", IDColumnName: "id", } // ErrRollbackImpossible is returned when trying to rollback a migration // that has no rollback function. ErrRollbackImpossible = errors.New("It's impossible to rollback this migration") // ErrNoMigrationDefined is returned when no migration is defined. ErrNoMigrationDefined = errors.New("No migration defined") // ErrMissingID is returned when the ID od migration is equal to "" ErrMissingID = errors.New("Missing ID in migration") // ErrNoRunnedMigration is returned when any runned migration was found while // running RollbackLast ErrNoRunnedMigration = errors.New("Could not find last runned migration") )
Functions ¶
This section is empty.
Types ¶
type InitSchemaFunc ¶
InitSchemaFunc is the func signature for initializing the schemas.
type Migrate ¶
type Migrate struct {
// contains filtered or unexported fields
}
Migrate represents a collection of all migrations of a database schemas.
func New ¶
New returns a new Gormigrate.
func (*Migrate) InitSchema ¶
func (m *Migrate) InitSchema(initSchema InitSchemaFunc)
InitSchema sets a function that is run if no migration is found. The idea is preventing to run all migrations when a new clean database is being migrating. In this function you should create all tables and foreign key necessary to your application.
func (*Migrate) Migrate ¶
Migrate executes all migrations that did not run yet.
func (*Migrate) RollbackLast ¶
RollbackLast undo the last migration
type MigrateFunc ¶
MigrateFunc is the func signature for migrating.
type Migration ¶
type Migration struct { // ID is the migration identifier. Usually a timestamp like "201601021504". ID string // Migrate is a function that will br executed while running this migration. Migrate MigrateFunc // Rollback will be executed on rollback. Can be nil. Rollback RollbackFunc }
Migration represents a database migration (a modification to be made on the database).
Click to show internal directories.
Click to hide internal directories.