[FIX] migration: rebuild the clone when the data migration fails

When OpenUpgrade fails, the intermediate <db>_upgrade_<N> database is left
half migrated. The clone step had already been recorded as done, so a rerun
skipped it and restarted OpenUpgrade on top of that broken clone.

Clear the clone flag on failure so the replay rebuilds the intermediate
database from the pristine source. Found by a real 12.0 -> 13.0 run: Ubuntu
unattended-upgrades restarted the PostgreSQL cluster mid-migration, Odoo lost
its connection, and the replay would have resumed on the damaged clone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mathieu Benoit 2026-08-01 02:38:54 -04:00
parent 8ce4b93292
commit 79a07ac577

View file

@ -1651,12 +1651,21 @@ class TodoUpgrade:
# half-migrated database. Stop here instead: the state stays
# unset, so a rerun replays this version.
if status:
# The intermediate database is now half migrated and must
# not be reused: drop the clone flag so the rerun rebuilds
# it from the pristine source. Without this the replay
# would restart OpenUpgrade on top of the broken clone.
lst_clone_odoo[index] = False
self.dct_progression["state_4_clone_odoo_lst"] = (
lst_clone_odoo
)
self.write_config()
print(
f"❌ -> Database migration to Odoo{next_version} FAILED"
f" (status {status}). Stopping before version"
f" {next_version + 1} to avoid migrating a broken"
" database. Fix the cause, then relaunch: this version"
" will be replayed."
f" replays from a fresh clone of '{database_name}'."
)
return