Documentation
¶
Overview ¶
Package migration provides automatic database migration capabilities Basic Usage sample:
Errors should be handled, but ignored for example code migrator, _ := migration.NewMigrator(db *sql.Connection) _ = migrator.AddMigrationList(arc.GetMigrationList()) // See below _ = migrator.Upgrade()
Example package that defines migrations var migrations embed.FS
const (
MIGRATION_CODE = "arc"
)
// GetMigrationList returns this packages migration list
func GetMigrationList() (ml *migration.List) {
return migration.NewList(MIGRATION_CODE, migration.MIGRATION_PATH, migrations)
}
Index ¶
Constants ¶
const ( ECode010201 = e.Code0102 + "01" ECode010202 = e.Code0102 + "02" ECode010203 = e.Code0102 + "03" ECode010204 = e.Code0102 + "04" ECode010205 = e.Code0102 + "05" ECode010206 = e.Code0102 + "06" )
const ( MIGRATION_TABLE = "skyrin_migration" MIGRATION_PATH = "db/migrations" MIGRATION_CODE = "migration" ECode010101 = e.Code0101 + "01" ECode010102 = e.Code0101 + "02" ECode010103 = e.Code0101 + "03" ECode010104 = e.Code0101 + "04" ECode010105 = e.Code0101 + "05" ECode010106 = e.Code0101 + "06" ECode010107 = e.Code0101 + "07" ECode010108 = e.Code0101 + "08" ECode010109 = e.Code0101 + "09" ECode01010A = e.Code0101 + "0A" ECode01010B = e.Code0101 + "0B" ECode01010C = e.Code0101 + "0C" ECode01010D = e.Code0101 + "0D" ECode01010E = e.Code0101 + "0E" ECode01010F = e.Code0101 + "0F" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
func (*File) GetVersionFromName ¶
GetVersionFromName parse the name for the version. The name is expected to have the version first as a 0 padded number and then an underscore. The rest of the name can be anything.
type List ¶
type List struct {
// contains filtered or unexported fields
}
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
NewMigrator initializes a new migrator
func (*Migrator) AddMigrationList ¶
AddMigrationList adds a migration list to the migrator