Skip to content

Commit

Permalink
atlasexec: amount arg and --to-tag flag to migrate down (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
masseelch authored Mar 12, 2024
1 parent 2fd13f9 commit 4a5bdfc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions atlasexec/atlas.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ type (
DirURL string
URL string
RevisionsSchema string
Amount uint64
ToVersion string
ToTag string
Vars Vars

// Not yet supported
Expand Down Expand Up @@ -325,6 +327,12 @@ func (c *Client) MigrateDown(ctx context.Context, params *MigrateDownParams) (*M
if params.ToVersion != "" {
args = append(args, "--to-version", params.ToVersion)
}
if params.ToTag != "" {
args = append(args, "--to-tag", params.ToTag)
}
if params.Amount > 0 {
args = append(args, strconv.FormatUint(params.Amount, 10))
}
args = append(args, params.Vars.AsArgs()...)
r, err := c.runCommand(ctx, args)
if cliErr := (cliError{}); errors.As(err, &cliErr) && cliErr.stderr == "" {
Expand Down
14 changes: 14 additions & 0 deletions atlasexec/atlas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,20 @@ func TestMigrateDown(t *testing.T) {
},
expect: "migrate down --format {{ json . }} --to-version 12345",
},
{
name: "with tag version",
params: &atlasexec.MigrateDownParams{
ToTag: "12345",
},
expect: "migrate down --format {{ json . }} --to-tag 12345",
},
{
name: "with amount",
params: &atlasexec.MigrateDownParams{
Amount: 10,
},
expect: "migrate down --format {{ json . }} 10",
},
} {
t.Run(tt.name, func(t *testing.T) {
_, err := c.MigrateDown(context.Background(), tt.params)
Expand Down

0 comments on commit 4a5bdfc

Please sign in to comment.