details:   https://code.tryton.org/tryton/commit/14e25c1bdddd
branch:    default
user:      Maxime Richez <[email protected]>
date:      Sat Mar 14 18:09:29 2026 +0100
description:
        Rename also columns in history table when renaming columns

        Closes #14561
diffstat:

 trytond/trytond/backend/postgresql/table.py |  6 ++++++
 trytond/trytond/backend/sqlite/table.py     |  5 +++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diffs (38 lines):

diff -r 9ea22f8cbadd -r 14e25c1bdddd trytond/trytond/backend/postgresql/table.py
--- a/trytond/trytond/backend/postgresql/table.py       Sat Mar 14 17:35:17 
2026 +0100
+++ b/trytond/trytond/backend/postgresql/table.py       Sat Mar 14 18:09:29 
2026 +0100
@@ -28,6 +28,7 @@
         self.__constraints = None
         self.__fk_deltypes = None
         self.__indexes = None
+        self._model = model
 
         transaction = Transaction()
         cursor = transaction.connection.cursor()
@@ -184,6 +185,11 @@
                         Identifier(old_name),
                         Identifier(new_name)))
                 self._update_definitions(columns=True)
+                if not self.history:
+                    history_table = self.table_name + '__history'
+                    if self.__class__.table_exist(history_table):
+                        history_h = self.__class__(self._model, True)
+                        history_h.column_rename(old_name, new_name)
             else:
                 logger.warning(
                     'Unable to rename column %s on table %s to %s.',
diff -r 9ea22f8cbadd -r 14e25c1bdddd trytond/trytond/backend/sqlite/table.py
--- a/trytond/trytond/backend/sqlite/table.py   Sat Mar 14 17:35:17 2026 +0100
+++ b/trytond/trytond/backend/sqlite/table.py   Sat Mar 14 18:09:29 2026 +0100
@@ -122,6 +122,11 @@
                         _escape_identifier(old_name),
                         _escape_identifier(new_name)))
                 self._update_definitions(columns=True)
+                if not self.history:
+                    history_table = self.table_name + '__history'
+                    if self.__class__.table_exist(history_table):
+                        history_h = self.__class__(self._model, True)
+                        history_h.column_rename(old_name, new_name)
             else:
                 logger.warning(
                     'Unable to rename column %s on table %s to %s.',

Reply via email to