Skip to content

Commit e77f161

Browse files
committed
[IMP] specific: check if custom table exists
When a custom table conflicts with a standard one we may choose to write a specific fix, using the `rename_custom_table` util to rename it. However, customers may remove that table in successive upgrade requests, making the call to `rename_table` unnecessary and the extra entry in the migration report wrong. Part-of: #91
1 parent 697c7fb commit e77f161

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/util/specific.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .misc import _cached
66
from .models import rename_model
77
from .modules import rename_module
8-
from .pg import column_exists, rename_table
8+
from .pg import column_exists, rename_table, table_exists
99
from .report import add_to_migration_reports
1010

1111
_logger = logging.getLogger(__name__)
@@ -84,6 +84,10 @@ def rename_custom_table(
8484
custom_module=None,
8585
report_details="",
8686
):
87+
if not table_exists(cr, table_name):
88+
_logger.warning("Table %r not found: skip renaming", table_name)
89+
return
90+
8791
rename_table(cr, table_name, new_table_name, remove_constraints=False)
8892

8993
module_details = " from module '{}'".format(custom_module) if custom_module else ""

0 commit comments

Comments
 (0)