Skip to content

Commit

Permalink
atlasexec: follow changes done to migrate down command (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
masseelch authored Mar 21, 2024
1 parent 4a5bdfc commit 085f965
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
31 changes: 24 additions & 7 deletions atlasexec/atlas_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type (
Version string `json:"Version,omitempty"`
Description string `json:"Description,omitempty"`
}
// AppliedFile is part of an ApplyReport containing information about an applied file in a migration attempt.
// AppliedFile is part of a MigrateApply containing information about an applied file in a migration attempt.
AppliedFile struct {
File
Start time.Time
Expand All @@ -26,6 +26,19 @@ type (
Error string // Error returned by the database.
}
}
// RevertedFile is part of a MigrateDown containing information about a reverted file in a downgrade attempt.
RevertedFile struct {
File
Start time.Time
End time.Time
Skipped int // Amount of skipped SQL statements in a partially applied file.
Applied []string // SQL statements applied with success
Scope string // Scope of the revert. e.g., statement, versions, etc.
Error *struct {
SQL string // SQL statement that failed.
Error string // Error returned by the database.
}
}
// MigrateApply contains a summary of a migration applying attempt on a database.
MigrateApply struct {
Pending []File `json:"Pending,omitempty"` // Pending migration files
Expand All @@ -40,12 +53,16 @@ type (
}
// MigrateDown contains a summary of a migration down attempt on a database.
MigrateDown struct {
Planned []File `json:"Planned,omitempty"` // Pending migration files
Applied []*AppliedFile `json:"Applied,omitempty"` // Applied files
Current string `json:"Current,omitempty"` // Current migration version
Target string `json:"Target,omitempty"` // Target migration version
Start time.Time
End time.Time
Planned []File `json:"Planned,omitempty"` // Pending migration files
Reverted []*RevertedFile `json:"Reverted,omitempty"` // Applied files
Current string `json:"Current,omitempty"` // Current migration version
Target string `json:"Target,omitempty"` // Target migration version
Total int `json:"Total,omitempty"` // Total number of migrations to revert
Start time.Time
End time.Time
// URL and Status are set only when the migration is planned or executed in the cloud.
URL string `json:"URL,omitempty"`
Status string `json:"Status,omitempty"`
// Error is set even then, if it was not caused by a statement in a migration file,
// but by Atlas, e.g. when committing or rolling back a transaction.
Error string `json:"Error,omitempty"`
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module ariga.io/atlas-go-sdk

go 1.21
go 1.22

toolchain go1.21.2
toolchain go1.22.0

require (
ariga.io/atlas v0.19.1-0.20240218093714-1a4929bdea1f
ariga.io/atlas v0.20.1-0.20240321075817-75fd3b1accbf
github.com/mattn/go-sqlite3 v1.14.17
github.com/stretchr/testify v1.8.4
)
Expand All @@ -23,7 +23,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ariga.io/atlas v0.19.1-0.20240218093714-1a4929bdea1f h1:76LCzgWyu26mvXyZG9rvreRey44cNCB05CZWgzv5Evo=
ariga.io/atlas v0.19.1-0.20240218093714-1a4929bdea1f/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
ariga.io/atlas v0.20.1-0.20240321075817-75fd3b1accbf h1:jpDQmb4YyO6SADrfS2+13p+dKOBfNJB80K8sTLQMr9g=
ariga.io/atlas v0.20.1-0.20240321075817-75fd3b1accbf/go.mod h1:VPlcXdd4w2KqKnH54yEZcry79UAhpaWaxEsmn5JRNoE=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
Expand Down Expand Up @@ -45,8 +45,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down

0 comments on commit 085f965

Please sign in to comment.