From e5658d1f61415054029b66cd2f703f1f40138460 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 18 Oct 2025 10:43:39 -0400 Subject: Add support for migration dependencies --- internal/models/migration.go | 19 +++++++++++-------- internal/models/migration_test.go | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'internal/models') diff --git a/internal/models/migration.go b/internal/models/migration.go index ed48073..baf5de9 100644 --- a/internal/models/migration.go +++ b/internal/models/migration.go @@ -7,9 +7,10 @@ import ( ) type Migration struct { - Version string - Message string - Applied bool + Version string + Message string + Applied bool + Dependencies []string } func NewTimestampMigration(version time.Time, message string) *Migration { @@ -19,16 +20,18 @@ func NewTimestampMigration(version time.Time, message string) *Migration { version.Year(), version.Month(), version.Day(), version.Hour(), version.Minute(), version.Second(), ), - Message: message, - Applied: false, + Message: message, + Applied: false, + Dependencies: []string{}, } } func NewSequentialMigration(version uint64, message string) *Migration { return &Migration{ - Version: fmt.Sprintf("%03d", version), - Message: message, - Applied: false, + Version: fmt.Sprintf("%03d", version), + Message: message, + Applied: false, + Dependencies: []string{}, } } diff --git a/internal/models/migration_test.go b/internal/models/migration_test.go index aae1cba..d7c1d6d 100644 --- a/internal/models/migration_test.go +++ b/internal/models/migration_test.go @@ -16,6 +16,7 @@ func TestNewTimestampMigration(t *testing.T) { check.Equal(t, m.Version, "20200101000000") check.Equal(t, m.Message, "test message") check.Equal(t, m.Applied, false) + check.DeepEqual(t, m.Dependencies, []string{}) } func TestNewSequentialMigration(t *testing.T) { @@ -30,6 +31,7 @@ func TestNewSequentialMigration(t *testing.T) { check.Equal(t, m.Version, "100") check.Equal(t, m.Message, "test message") check.Equal(t, m.Applied, false) + check.DeepEqual(t, m.Dependencies, []string{}) } func TestName(t *testing.T) { -- cgit v1.2.3