Skip to content

Commit

Permalink
Fix migration checksum comparison during migrate info
Browse files Browse the repository at this point in the history
When running `sqlx migrate info`, the applied migrations checksums are
compared against the checksums of the local migration files. While the
checksums of applied migrations are stored correctly in the database as
sha384sum values, the `migrate info` command was incorrectly comparing
these against the checksums of down-migrations in cases where reversible
migrations are being used (e.g. when migrations end in `.up.sql` and
`.down.sql`).

This fixes the issue by skipping over any migrations with the
`MigrationType::ReversibleDown` type, using the same idiom as is used
when running migrations (with `migrate run`).

Issue introduced in launchbadge#1680
Partially resolves launchbadge#1158
  • Loading branch information
mdtusz committed Jun 2, 2022
1 parent 20d61f4 commit 291d3c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sqlx-cli/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ pub async fn info(migration_source: &str, uri: &str) -> anyhow::Result<()> {
.collect();

for migration in migrator.iter() {
if migration.migration_type.is_down_migration() {
// Skipping down migrations
continue;
}


let applied = applied_migrations.get(&migration.version);

let (status_msg, mismatched_checksum) = if let Some(applied) = applied {
Expand Down

0 comments on commit 291d3c5

Please sign in to comment.