DB Migrations #67

Merged
konrad merged 44 commits from feature/migrations into master 2019-03-29 17:54:36 +00:00
2 changed files with 4 additions and 0 deletions
Showing only changes of commit 760c4889c2 - Show all commits

View File

@ -56,6 +56,7 @@ func initMigration(x *xorm.Engine) *xormigrate.Xormigrate {
return m
}
// Migrate runs all migrations
func Migrate(x *xorm.Engine) {
m := initMigration(x)
err := m.Migrate()
@ -65,6 +66,7 @@ func Migrate(x *xorm.Engine) {
log.Log.Info("Ran all migrations successfully.")
}
// ListMigrations pretty-prints a list with all migrations.
func ListMigrations() {
x, err := db.CreateDBEngine()
if err != nil {
@ -88,6 +90,7 @@ func ListMigrations() {
table.Render()
}
// Rollback rolls back all migrations until a certain point.
func Rollback(migrationID string) {
m := initMigration(nil)
err := m.RollbackTo(migrationID)

View File

@ -31,6 +31,7 @@ var (
x *xorm.Engine
)
// GetTables returns all structs which are also a table.
func GetTables() []interface{} {
return []interface{}{
&User{},