2021-12-01 19:11:29 +07:00
|
|
|
package models
|
2020-07-16 12:56:08 +07:00
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
// SchemaMigration represents an intended migration.
|
|
|
|
type SchemaMigration struct {
|
|
|
|
Version int
|
|
|
|
Name string
|
|
|
|
Provider string
|
|
|
|
Up bool
|
|
|
|
Query string
|
|
|
|
}
|
2020-07-16 12:56:08 +07:00
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
// Before returns the version the schema should be at Before the migration is applied.
|
|
|
|
func (m SchemaMigration) Before() (before int) {
|
|
|
|
if m.Up {
|
|
|
|
return m.Version - 1
|
|
|
|
}
|
2020-07-16 12:56:08 +07:00
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
return m.Version
|
2020-07-16 12:56:08 +07:00
|
|
|
}
|
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
// After returns the version the schema will be at After the migration is applied.
|
|
|
|
func (m SchemaMigration) After() (after int) {
|
|
|
|
if m.Up {
|
|
|
|
return m.Version
|
|
|
|
}
|
|
|
|
|
|
|
|
return m.Version - 1
|
2020-07-16 12:56:08 +07:00
|
|
|
}
|