From 568ad3774a3deb5516971758d15c753b83318d6e Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 28 Mar 2019 19:50:41 +0100 Subject: [PATCH] Added rollback cmd --- pkg/migration/migration.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/migration/migration.go b/pkg/migration/migration.go index 55881189f..9b04be248 100644 --- a/pkg/migration/migration.go +++ b/pkg/migration/migration.go @@ -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.