Ensure migration list is sorted
This commit is contained in:
parent
533158b55c
commit
270215b260
@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sort"
|
||||
|
||||
"github.com/Jaculabilis/intake/core"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
@ -35,12 +36,17 @@ func migrate(listOnly bool) {
|
||||
log.Fatalf("error: failed to init database: %v", err)
|
||||
}
|
||||
if listOnly {
|
||||
pending, err := core.GetPendingMigrations(db)
|
||||
complete, err := core.GetPendingMigrations(db)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for name, complete := range pending {
|
||||
if complete {
|
||||
names := make([]string, 0, len(complete))
|
||||
for name := range complete {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
if complete[name] {
|
||||
fmt.Printf("[x] %s\n", name)
|
||||
} else {
|
||||
fmt.Printf("[ ] %s\n", name)
|
||||
|
Loading…
Reference in New Issue
Block a user