Allow --target-version to revert migrations with -f
/--force
flag
#3727
Labels
enhancement
New feature or request
-f
/--force
flag
#3727
I have found these related issues/pull requests
Relates to #2538
Description
sqlx migrate run --target-version [version]
is only allowed to applyup
migrations, and will give an error if the target version is older than the latest applied migration. Likewise,revert
is only allowed to applydown
migrations; there is no command that migrates to a specific version regardless of the current version of the database.I'm working on a Helm chart that deploys an application that requires a database. An init container first fetches the complete list of migrations, and runs those migrations up to the required version with a superuser account, after which the application itself can run with fewer privileges. This works great, but Helm charts can also be rolled back to previous versions, and while this isn't super common, doing so will likely break the application if the database isn't rolled back properly as well. I cannot expect users to revert the migrations manually, but I do want to support rollbacks, so it would be useful if the init container could revert migrations as well.
Prefered solution
A
-f
/--force
flag that allowssqlx migrate run --target-version [version]
to applydown
migrations if necessary.In the meantime, I can apply both
sqlx migrate run --target-version [version]
andsqlx migrate revert --target-version [version]
, knowing that one of them will return an error.Is this a breaking change? Why or why not?
The new functionality only applies when using a previously non-existent flag, and supplying non-existent flags to the CLI will currently throw an error, so it's not a breaking change.
The text was updated successfully, but these errors were encountered: