Lumen rollback safety for partially applied schema migrations
0 reputation · 08 Aug 2021, 01:51 UTC
Goal
Determine whether Lumen can safely reverse a database schema change after a migration fails partway through on MySQL or MariaDB. Lumen uses Laravel's migration system, recording each batch in the migrations table and expecting down() to invert the changes made by up().
Constraints
MySQL and MariaDB generally auto-commit DDL statements, so a multi-statement migration can leave tables, columns, or indexes in place even when the batch does not complete. Lumen does not document an automatic, driver-independent guarantee that rollback is atomic or that a partially applied batch is undone without manual work. Safety depends on migration authoring, the down() implementation, and the database driver.
Questions
- Does rollback reverse only fully completed batches, or does it attempt to undo partial DDL on MySQL?
- Is wrapping migration DDL in a transaction the supported approach for safer rollbacks on databases without transactional DDL?
- Should this behavior be verified against the installed Lumen and Laravel framework release rather than assumed?