From 79a07ac57707060ea968db456f5a561445552187 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 1 Aug 2026 02:38:54 -0400 Subject: [PATCH] [FIX] migration: rebuild the clone when the data migration fails When OpenUpgrade fails, the intermediate _upgrade_ 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) --- script/todo/todo_upgrade.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/script/todo/todo_upgrade.py b/script/todo/todo_upgrade.py index 4e15955..09c5275 100755 --- a/script/todo/todo_upgrade.py +++ b/script/todo/todo_upgrade.py @@ -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