From 72efd7a9dea2cc08a552b4371d215d17da3e14e1 Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Sat, 14 Mar 2026 18:09:29 +0100 Subject: [PATCH] Rename also columns in history table when renaming columns Closes #14561 --- trytond/trytond/backend/postgresql/table.py | 6 ++++++ trytond/trytond/backend/sqlite/table.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/trytond/trytond/backend/postgresql/table.py b/trytond/trytond/backend/postgresql/table.py index 85c4ff440f..00f215e810 100644 --- a/trytond/trytond/backend/postgresql/table.py +++ b/trytond/trytond/backend/postgresql/table.py @@ -28,6 +28,7 @@ class TableHandler(TableHandlerInterface): self.__constraints = None self.__fk_deltypes = None self.__indexes = None + self._model = model transaction = Transaction() cursor = transaction.connection.cursor() @@ -184,6 +185,11 @@ class TableHandler(TableHandlerInterface): 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 --git a/trytond/trytond/backend/sqlite/table.py b/trytond/trytond/backend/sqlite/table.py index 4d95b7fa90..308227a93b 100644 --- a/trytond/trytond/backend/sqlite/table.py +++ b/trytond/trytond/backend/sqlite/table.py @@ -122,6 +122,11 @@ class TableHandler(TableHandlerInterface): _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.',