Added list cmd
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
50f6e2cb7c
commit
7eb5321690
|
@ -21,7 +21,9 @@ import (
|
|||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/models"
|
||||
"github.com/go-xorm/xorm"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/spf13/viper"
|
||||
"os"
|
||||
"sort"
|
||||
"src.techknowlogick.com/xormigrate"
|
||||
)
|
||||
|
@ -63,7 +65,27 @@ func Migrate(x *xorm.Engine) {
|
|||
}
|
||||
|
||||
func ListMigrations() {
|
||||
x, err := db.CreateDBEngine()
|
||||
if err != nil {
|
||||
log.Log.Fatalf("Could not connect to db: %v", err.Error())
|
||||
}
|
||||
ms := []*xormigrate.Migration{}
|
||||
err = x.Find(&ms)
|
||||
if err != nil {
|
||||
log.Log.Fatalf("Error getting migration table: %v", err.Error())
|
||||
}
|
||||
|
||||
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})
|
||||
|
||||
for _, m := range ms {
|
||||
table.Append([]string{m.ID, m.Description})
|
||||
}
|
||||
table.Render()
|
||||
}
|
||||
|
||||
func Rollback(until string) {
|
||||
|
|
Loading…
Reference in New Issue