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 ( ECode000201 = e.Code0002 + "01" ECode000202 = e.Code0002 + "02" ECode000203 = e.Code0002 + "03" ECode000204 = e.Code0002 + "04" ECode000205 = e.Code0002 + "05" ECode000206 = e.Code0002 + "06" )
const ( MIGRATION_TABLE = "skyrin_migration" MIGRATION_PATH = "db/migrations" MIGRATION_CODE = "migration" ECode000101 = e.Code0001 + "01" ECode000102 = e.Code0001 + "02" ECode000103 = e.Code0001 + "03" ECode000104 = e.Code0001 + "04" ECode000105 = e.Code0001 + "05" ECode000106 = e.Code0001 + "06" ECode000107 = e.Code0001 + "07" ECode000108 = e.Code0001 + "08" ECode000109 = e.Code0001 + "09" ECode00010A = e.Code0001 + "0A" ECode00010B = e.Code0001 + "0B" ECode00010C = e.Code0001 + "0C" ECode00010D = e.Code0001 + "0D" ECode00010E = e.Code0001 + "0E" ECode00010F = e.Code0001 + "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 ¶
func NewMigrator(db *sql.Connection) (m *Migrator, err error)
NewMigrator initializes a new migrator
func (*Migrator) AddMigrationList ¶
AddMigrationList adds a migration list to the migrator