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