Documentation ¶
Overview ¶
Package migrate allows to easily manage database migration with gorm v2
Index ¶
Constants ¶
View Source
const ( // StepIssueUpMissing means the issue is a missing upgrade method. StepIssueUpMissing = "up_missing" // StepIssueDownMissing means the issue is a missing downgrade method. StepIssueDownMissing = "down_missing" // StepIssueBadlyOrdered means the issue is badly ordered. StepIssueBadlyOrdered = "badly_ordered" )
View Source
const ( // UpFull is a complete upgrade migration. UpFull = 100000 // DownFull is a complete downgrade migration. DownFull = -100000 // UpOne is a single upgrade migration. UpOne = 1 // DownOne is a single downgrade migration. DownOne = -1 )
Variables ¶
View Source
var ( // ErrBadDirection is returned when the direction is equal to 0. ErrBadDirection = fmt.Errorf("bad direction") // ErrInconsistentSteps is returned when we couldn't apply all the migration steps ups & downs. ErrInconsistentSteps = fmt.Errorf("inconsistent steps") )
Functions ¶
func ValidateSteps ¶ added in v0.2.0
func ValidateSteps(db *gorm.DB, steps Migrations, dual bool) error
ValidateSteps validates that all the steps can be applied up & down.
Types ¶
type ErrBadMigration ¶
type ErrBadMigration struct { Name string // Name of the migration that has an issue Type string // Type of the issue }
ErrBadMigration is reported when a migration has a bad definition.
func (*ErrBadMigration) Error ¶
func (e *ErrBadMigration) Error() string
type MigrationMethod ¶
MigrationMethod declares the method we want to apply to the database.
type MigrationStep ¶
type MigrationStep struct { Name string // Name is the name of the migration Up MigrationMethod // Up is the upgrade migration method Down MigrationMethod // Down is the downgrade migration method }
MigrationStep declares a migration.
type Migrations ¶
type Migrations []*MigrationStep
Migrations contains the migration steps we want to apply.
Click to show internal directories.
Click to hide internal directories.