mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[FIX] base_comment_template: Incorrect m2m column names + script + avoid FK constraint
- The name of the columns were swapped, so better to fix it for avoiding mistakes due to this. - Migration script for detecting the condition and swap column names. - On v12 > v13 migration, include JOINs for avoiding FK constraint, which `ON CONFLICT` clause doesn't protect.
This commit is contained in:
committed by
Víctor Martínez
parent
19b7692ee8
commit
34333c4216
21
base_comment_template/migrations/13.0.3.0.0/pre-migration.py
Normal file
21
base_comment_template/migrations/13.0.3.0.0/pre-migration.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2021 Tecnativa - Pedro M: Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from openupgradelib import openupgrade # pylint: disable=W7936
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
if openupgrade.table_exists(env.cr, "base_comment_template_res_partner_rel"):
|
||||
# Swap column names, as they were incorrect
|
||||
env.cr.execute(
|
||||
"ALTER TABLE base_comment_template_res_partner_rel "
|
||||
"RENAME base_comment_template_id TO temp"
|
||||
)
|
||||
env.cr.execute(
|
||||
"ALTER TABLE base_comment_template_res_partner_rel "
|
||||
"RENAME res_partner_id TO base_comment_template_id"
|
||||
)
|
||||
env.cr.execute(
|
||||
"ALTER TABLE base_comment_template_res_partner_rel "
|
||||
"RENAME temp TO res_partner_id"
|
||||
)
|
||||
Reference in New Issue
Block a user