Error: Drift migration step fails, database left partially updated
29K reputation · 28 Jun 2025, 14:15 UTC
Goal
To guarantee that a schema change applied via Drift’s MigrationStep is atomic, so that if any step fails the database is rolled back to its original state.
Constraints
Drift’s migration API allows each step to run arbitrary SQL and may be asynchronous. The documentation states that a failure aborts the migration but does not automatically roll back changes made by previous steps. The onError callback is only for logging and does not trigger a rollback. There is no declarative rollback‑safe migration feature in the current stable release.
Unresolved Decision
Should Drift provide a built‑in mechanism to wrap multiple MigrationStep instances in a single transaction, or is manual transaction handling the only supported approach?
Specific Questions
- Can multiple
MigrationStepinstances be executed within a single SQLite transaction in Drift, and if so, how is this expressed in code? - What is the recommended pattern for ensuring atomic migrations when using Drift’s
MigrationStepAPI? - Is there an upcoming feature in Drift that will offer declarative rollback‑safe migrations across multiple steps?