Skip to content
Open
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
22 changes: 22 additions & 0 deletions openupgrade_scripts/scripts/im_livechat/19.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ def im_livechat_channel_rule_chatbot_enabled_condition(env):
)


def discuss_channel_livechat_end_dt(env):
"""19.0 replaces the ``livechat_active`` boolean with ``livechat_end_dt``.
Without a backfill every historically closed session migrates as still
open (multi-year durations, live status in the new dashboards). Clearing
the status also satisfies CHECK(livechat_end_dt IS NULL OR livechat_status
IS NULL)."""
if not openupgrade.column_exists(env.cr, "discuss_channel", "livechat_active"):
return
openupgrade.logged_query(
env.cr,
"""
UPDATE discuss_channel
SET livechat_end_dt = COALESCE(write_date, create_date),
livechat_status = NULL
WHERE channel_type = 'livechat'
AND livechat_active IS NOT TRUE
AND livechat_end_dt IS NULL
""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "im_livechat", "19.0.1.0/noupdate_changes.xml")
Expand All @@ -43,3 +64,4 @@ def migrate(env, version):
)
chatbot_script_step_message(env)
im_livechat_channel_rule_chatbot_enabled_condition(env)
discuss_channel_livechat_end_dt(env)
Loading