Hope that the sqlx migrate run
command can have the functionality to only write to the _sql_migrations table without executing SQL statements.
#3706
Labels
enhancement
New feature or request
I have found these related issues/pull requests
none
Description
I currently have an old project that I want to refactor using Rust and SQLx.
This project already has a database that includes data structures and data. To use sqlx for migration management of the existing database, I wrote up migration files and down migration files that are consistent with the current state of the existing database.
But when I execute
sqlx migrate run
, it repeatedly creates tables, indexes, and other statements, causing errors.The up migration file and down migration file after removing sensitive information are as follows:
0001_init.up.sql
0001_init.down.sql
Prefered solution
Add command:
sqlx migrate run --fake --target-version [version]
The meaning of this command:In the interval [1, version], do not execute the SQL statements in the migration files; instead, set the status of the migration files to success and write to the _sqlx_migrations table.
--fake: type bool default false
Is this a breaking change? Why or why not?
This is not a breaking change.
First, this is about adding new features rather than modifying existing ones, so it will not break any current functionality.
Secondly, the default value of --fake is false, so the meaning of
sqlx migrate run
has not changed, maintaining compatibility with the original usage.The text was updated successfully, but these errors were encountered: