aboutsummaryrefslogtreecommitdiffstats
path: root/internal/models
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-11-13 22:20:16 -0800
committerEugene Triguba <hello@eugenetriguba.com>2026-11-13 22:20:16 -0800
commit7026e3861a5712ced6f2006f282c8386b4db106e (patch)
tree18db906e76c1736a831f345b4832db91964c960a /internal/models
parentRemove timestamp version style in favor of always using sequential (diff)
downloadcli-7026e3861a5712ced6f2006f282c8386b4db106e.zip
Pad new migrations to 4 digits
Diffstat (limited to 'internal/models')
-rw-r--r--internal/models/migration.go2
-rw-r--r--internal/models/migration_test.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/internal/models/migration.go b/internal/models/migration.go
index 44608f9..74a1536 100644
--- a/internal/models/migration.go
+++ b/internal/models/migration.go
@@ -13,7 +13,7 @@ type Migration struct {
func NewMigration(version uint64, message string) *Migration {
return &Migration{
- Version: fmt.Sprintf("%03d", version),
+ Version: fmt.Sprintf("%04d", version),
Message: message,
Applied: false,
}
diff --git a/internal/models/migration_test.go b/internal/models/migration_test.go
index 87b98e4..91aed2e 100644
--- a/internal/models/migration_test.go
+++ b/internal/models/migration_test.go
@@ -10,13 +10,13 @@ import (
func TestNewMigration(t *testing.T) {
m := models.NewMigration(1, "test message")
- check.Equal(t, m.Version, "001")
+ check.Equal(t, m.Version, "0001")
check.Equal(t, m.Message, "test message")
check.Equal(t, m.Applied, false)
m = models.NewMigration(100, "test message")
- check.Equal(t, m.Version, "100")
+ check.Equal(t, m.Version, "0100")
check.Equal(t, m.Message, "test message")
check.Equal(t, m.Applied, false)
}
@@ -31,12 +31,12 @@ func TestName(t *testing.T) {
// Underscores are used to separate version and message.
{
migration: models.NewMigration(1, "test_message"),
- expectedName: "001_test_message",
+ expectedName: "0001_test_message",
},
// Leading/Trailing spaces trimmed, lowercased, and spaces converted to underscores.
{
migration: models.NewMigration(1, " teST mesSAGE "),
- expectedName: "001_test_message",
+ expectedName: "0001_test_message",
},
}