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
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:
The meaning of this command:The [version1 version2 ...] do not execute the SQL statements in the migration files; instead, add new migration record and set the status of the migration files to success and write to the _sqlx_migrations table.
The meaning of this command:The [version1 version2 ...] do not execute the SQL statements in the migration files; instead, update migration record and set the status of the migration files to success and update to the _sqlx_migrations table.
hushoujier
changed the title
Hope that the sqlx migrate run command can have the functionality to only write to the _sql_migrations table without executing SQL statements.
Support manual modification of the _sql_migrations table.
Feb 10, 2025
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 fake --type add --target-versions [version1 version2 ...]
The meaning of this command:The [version1 version2 ...] do not execute the SQL statements in the migration files; instead, add new migration record and set the status of the migration files to success and write to the _sqlx_migrations table.
Add command:
sqlx migrate fake --type update --target-versions [version1 version2 ...]
The meaning of this command:The [version1 version2 ...] do not execute the SQL statements in the migration files; instead, update migration record and set the status of the migration files to success and update to the _sqlx_migrations table.
Add command:
sqlx migrate fake --type delete --target-versions [version1 version2 ...]
The meaning of this command:delete the [version1 version2 ...] migration record from the _sqlx_migrations table.
Is this a breaking change? Why or why not?
This is not a breaking change.
This is about adding new features rather than modifying existing ones, so it will not break any current functionality.
The text was updated successfully, but these errors were encountered: