Ensure migration list is sorted

This commit is contained in:
Tim Van Baak 2025-05-02 12:10:17 -07:00
parent 533158b55c
commit 270215b260

View File

@ -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)