details:   https://code.tryton.org/tryton/commit/37e965ef7d10
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Tue Feb 10 18:21:47 2026 +0100
description:
        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
diffstat:

 trytond/trytond/backend/postgresql/table.py |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (16 lines):

diff -r 7b62424ca530 -r 37e965ef7d10 trytond/trytond/backend/postgresql/table.py
--- a/trytond/trytond/backend/postgresql/table.py       Thu Jan 15 22:34:01 
2026 +0100
+++ b/trytond/trytond/backend/postgresql/table.py       Tue Feb 10 18:21:47 
2026 +0100
@@ -164,6 +164,12 @@
                 and not cls.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

Reply via email to