diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-10-18 10:43:39 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-26 11:46:57 -0500 |
| commit | e5658d1f61415054029b66cd2f703f1f40138460 (patch) | |
| tree | c609e209f4cebc62dd985d1b773558f47eb73bf6 /internal/models | |
| parent | Add is-branch main check for docs deployment (diff) | |
| download | cli-e5658d1f61415054029b66cd2f703f1f40138460.zip | |
Add support for migration dependencies
Diffstat (limited to 'internal/models')
| -rw-r--r-- | internal/models/migration.go | 19 | ||||
| -rw-r--r-- | internal/models/migration_test.go | 2 |
2 files changed, 13 insertions, 8 deletions
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) { |