details: https://code.tryton.org/tryton/commit/4e3802e93998
branch: 6.0
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
(grafted from 14e25c1bddddbe51ddbae31e3dd6b4cec72d49f5)
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 b8c6c0ce6464 -r 4e3802e93998 trytond/trytond/backend/postgresql/table.py
--- a/trytond/trytond/backend/postgresql/table.py Mon Mar 02 15:23:13
2026 +0100
+++ b/trytond/trytond/backend/postgresql/table.py Sat Mar 14 18:09:29
2026 +0100
@@ -24,6 +24,7 @@
self._constraints = []
self._fk_deltypes = {}
self._indexes = []
+ self._model = model
transaction = Transaction()
cursor = transaction.connection.cursor()
@@ -145,6 +146,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 b8c6c0ce6464 -r 4e3802e93998 trytond/trytond/backend/sqlite/table.py
--- a/trytond/trytond/backend/sqlite/table.py Mon Mar 02 15:23:13 2026 +0100
+++ b/trytond/trytond/backend/sqlite/table.py Sat Mar 14 18:09:29 2026 +0100
@@ -127,6 +127,11 @@
if self.column_exist(old_name):
if not self.column_exist(new_name):
self._recreate_table({old_name: {'name': new_name}})
+ 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.',