Shopware 6 upgrade wizard rollback limits when migrations fail midway
0 reputation · 24 Dec 2023, 06:22 UTC
0 reputation · 24 Dec 2023, 06:22 UTC
The Shopware 6 upgrade wizard performs incremental schema migrations but provides no automated rollback mechanism. If a migration fails partway through, the database may contain a mix of old and new schema elements, and obsolete tables from prior versions are not purged automatically.
Determine the practical boundaries of recovery after a failed upgrade without restoring from a full backup, specifically whether re-running migrations or clearing caches can reliably revert schema changes that were committed before the failure point.
The wizard logs actions to var/log/upgrade.log and checks plugin compatibility, yet it does not revert incompatible plugins or undo database alterations made prior to the error. Documentation recommends clearing cache and re-running migrations, but it is unclear whether this approach can safely unwind partial schema changes or whether orphaned tables and columns remain.
What is the documented behavior of the migration runner when re-executed after a failure? Does it detect and reverse already-applied migrations, or only attempt pending ones? Are there supported procedures to identify and remove orphaned schema objects left by an interrupted upgrade?
31275 reputation · 24 Dec 2023, 09:36 UTC
No. Re-running the Shopware 6 upgrade wizard or clearing the cache does not revert schema changes that were committed before the failure point. The migration runner is forward-only: on re-execution it skips migrations already recorded as executed and attempts only the pending ones. There is no supported automatic rollback, and no built-in procedure that reliably identifies and removes orphaned tables or columns left behind by an interrupted upgrade. Without a pre-upgrade database snapshot, returning to the exact pre-failure state is not possible.
Confirmed behavior of the migration runner: Shopware 6 tracks executed migrations in a tracking table (the Doctrine-style migration version table). When the runner starts, it compares available migration classes against that table and executes only those not yet recorded. A migration that completed and was recorded before the failure will be skipped on every subsequent run — it will not be reversed, even if its changes are part of the problem.
Likely explanation for the mixed state: the wizard runs migrations incrementally, and each successfully executed migration is typically committed independently rather than inside one giant transaction spanning the whole upgrade. So a failure at migration N leaves migrations 1..N-1 permanently applied. Clearing var/cache/ only refreshes compiled container, proxy, and configuration artifacts; it touches no schema objects, so it cannot unwind anything.
var/log/upgrade.log for the last successfully executed migration and the error that stopped the run.bin/console doctrine:migrations:statusThis shows which migrations are recorded as executed and which remain pending — the authoritative map of your partial state.bin/console database:migrate --all (command names vary slightly by Shopware minor version — verify with bin/console list). The goal is to complete the upgrade, not to go backward.bin/console cache:clear) so the application reflects the finished schema.Tables and columns left over from prior versions are not purged automatically, and Shopware ships no supported cleanup tool that diffs your live schema against a canonical one. The practical options are:
This assumes a Shopware 6.x line using the standard Doctrine-based migration component; exact console command names and the migration tracking table name can differ across minor versions, so verify against your installed version. One detail that would change the recommendation: the exact error message and migration name at the failure point in upgrade.log — if the failing migration itself partially executed before erroring (some DDL auto-commits and cannot be rolled back transactionally), manual schema repair may be needed before pending migrations can proceed.
The durable lesson: take a database dump immediately before every upgrade. Forward-only migration runners make the pre-upgrade snapshot the only true rollback mechanism.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.