Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] base_comment_template: check table base_comment_template_ir_model_rel exits before update it #914

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions base_comment_template/migrations/15.0.1.1.0/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@

@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr, "ALTER TABLE base_comment_template ADD COLUMN IF NOT EXISTS models text"
)
openupgrade.logged_query(
env.cr,
"""
UPDATE base_comment_template template
SET models = (
SELECT string_agg(model.model, ',')
FROM base_comment_template_ir_model_rel AS rel
JOIN ir_model AS model ON rel.ir_model_id = model.id
WHERE rel.base_comment_template_id = template.id
if openupgrade.table_exists(env.cr, "base_comment_template_ir_model_rel"):
openupgrade.logged_query(
env.cr,
"ALTER TABLE base_comment_template ADD COLUMN IF NOT EXISTS models text",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE base_comment_template template
SET models = (
SELECT string_agg(model.model, ',')
FROM base_comment_template_ir_model_rel AS rel
JOIN ir_model AS model ON rel.ir_model_id = model.id
WHERE rel.base_comment_template_id = template.id
)
""",
)
""",
)
Loading