rust database_error ai_generated true

error returned from database: migration checksum mismatch for migration

ID: rust/rust-sqlx-migration-error

Also available as: JSON · Markdown
83%Fix Rate
85%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1 active

Root Cause

An already-applied migration was modified. SQLx stores checksums to ensure migration integrity.

generic

Workarounds

  1. 90% success Create a new migration with the corrective changes instead of modifying the existing one
    sqlx migrate add fix_previous_migration
    # Write ALTER TABLE or corrective SQL in the new migration

    Sources: https://docs.rs/sqlx/latest/sqlx/migrate/index.html

  2. 88% success For development only: drop and recreate the database
    sqlx database drop
    sqlx database create
    sqlx migrate run

    Sources: https://docs.rs/sqlx/latest/sqlx/migrate/index.html

Dead Ends

Common approaches that don't work:

  1. Delete the _sqlx_migrations table to re-run all migrations 75% fail

    Re-running CREATE TABLE migrations on existing tables causes SQL errors; data may be lost

Error Chain

Leads to:
Preceded by:
Frequently confused with: