You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accept river migrate-down --target-version 0 to remove all River tables (#966)
There was a bit of an unfortunate UX quirk in the CLI wherein to remove
all River tables you needed to specify a special value of
`--target-version -1`. This is a relic of how the CLI uses `rivermigrate`
internally, and `rivermigrate`'s options have a `TargetVersion int` that
makes 0 a reserved value for when the option is unset.
It seems like we can do a little better here for the CLI, so here we add
some code that lets 0 or -1 be used as a `--target-version` to apply all
down migrations. We do this by changing the CLI default value to the
sentinel value -2, which we change back to a real default before
forwarding onto `rivermigrate`.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17
17
18
18
- Remove unecessary transactions where a single database operation will do. This reduces the number of subtransactions created which can be an operational benefit it many cases. [PR #950](https://github.com/riverqueue/river/pull/950)
19
19
- Bring all driver tests into separate package so they don't leak dependencies. This removes dependencies from the top level `river` package that most River installations won't need, thereby reducing the transitive dependency load of most River installations. [PR #955](https://github.com/riverqueue/river/pull/955).
20
+
- The River CLI now accepts a `--target-version` of 0 with `river migrate-down` to run all down migrations and remove all River tables (previously, -1 was used for this; -1 still works, but now 0 also works). [PR #966](https://github.com/riverqueue/river/pull/966).
Copy file name to clipboardExpand all lines: cmd/river/rivercli/river_cli.go
+30-3Lines changed: 30 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -173,7 +173,7 @@ to use a development database only.
173
173
cmd.Flags().StringVar(&opts.Line, "line", "", "migration line to operate on (default: main)")
174
174
cmd.Flags().IntVar(&opts.MaxSteps, "max-steps", 0, "maximum number of steps to migrate")
175
175
cmd.Flags().BoolVar(&opts.ShowSQL, "show-sql", false, "show SQL of each migration")
176
-
cmd.Flags().IntVar(&opts.TargetVersion, "target-version", 0, "target version to migrate to (final state includes this version, but none after it)")
176
+
cmd.Flags().IntVar(&opts.TargetVersion, "target-version", targetVersionCLIFlagDefault, "target version to migrate to (final state includes this version, but none after it); when migrating down, use 0 to apply all down migrations")
0 commit comments