From aaf1dbd92f72dd6dfe11afda99f836a954795a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Tue, 10 Feb 2026 18:21:47 +0100 Subject: [PATCH] Rename history sequence when the table is renamed Just like in ff68233bdeb1 we need to also rename the history sequence name as the migration to identity relies on the sequence name including the table name. Closes #14598 (grafted from 37e965ef7d10183ef37a2b627b25bc6366421122) --HG-- branch : 6.0 --- trytond/trytond/backend/postgresql/table.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trytond/trytond/backend/postgresql/table.py b/trytond/trytond/backend/postgresql/table.py index 927c8f6407..852cf09cef 100644 --- a/trytond/trytond/backend/postgresql/table.py +++ b/trytond/trytond/backend/postgresql/table.py @@ -125,6 +125,12 @@ class TableHandler(TableHandlerInterface): and not TableHandler.table_exist(new_history)): cursor.execute('ALTER TABLE "%s" RENAME TO "%s"' % (old_history, new_history)) + # Migrate from 6.6: rename old history sequence + old_history_sequence = f'{old_name}__history' + '___id_seq' + new_history_sequence = f'{new_name}__history' + '___id_seq' + transaction.database.sequence_rename( + transaction.connection, old_history_sequence, + new_history_sequence) def column_exist(self, column_name): return column_name in self._columns