Added rollback cmd
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2019-03-28 19:50:41 +01:00
parent 7eb5321690
commit 568ad3774a
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 3 deletions

View File

@ -62,6 +62,7 @@ func Migrate(x *xorm.Engine) {
if err != nil {
log.Log.Fatalf("Migration failed: %v", err)
}
log.Log.Info("Ran all migrations successfully.")
}
func ListMigrations() {
@ -78,7 +79,6 @@ func ListMigrations() {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"ID", "Description"})
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetHeaderColor(tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor})
@ -88,8 +88,13 @@ func ListMigrations() {
table.Render()
}
func Rollback(until string) {
func Rollback(migrationID string) {
m := initMigration(nil)
err := m.RollbackTo(migrationID)
if err != nil {
log.Log.Fatalf("Could not rollback: %v", err)
}
log.Log.Info("Rolled back successfully.")
}
// Deletes a column from a table. All arguments are strings, to let them be standalone and not depending on any struct.