From b682e9a218bf856ffafca2c26ef3784d5d55234b Mon Sep 17 00:00:00 2001 From: Don Kendall Date: Thu, 16 Jul 2026 16:40:39 -0400 Subject: [PATCH] [OU-FIX] im_livechat: backfill livechat_end_dt for closed sessions 19.0 replaces discuss_channel.livechat_active (boolean) with livechat_end_dt. Upstream's im_livechat migration doesn't backfill it, so every historically closed livechat session migrates as still-open (multi-year durations, live status in the new dashboards). Set livechat_end_dt from write_date and clear livechat_status for non-active sessions. --- .../im_livechat/19.0.1.0/post-migration.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/openupgrade_scripts/scripts/im_livechat/19.0.1.0/post-migration.py b/openupgrade_scripts/scripts/im_livechat/19.0.1.0/post-migration.py index 5aa89d143a0..03591793d5f 100644 --- a/openupgrade_scripts/scripts/im_livechat/19.0.1.0/post-migration.py +++ b/openupgrade_scripts/scripts/im_livechat/19.0.1.0/post-migration.py @@ -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") @@ -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)