Skip to content

Commit

Permalink
legacymigrate: fix more foreign key issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 30, 2024
1 parent 39a0d71 commit 4e19e36
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/mautrix-whatsapp/legacymigrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SELECT
jid, -- id
CASE WHEN receiver LIKE '%@s.whatsapp.net' THEN replace(receiver, '@s.whatsapp.net', '') ELSE '' END, -- receiver
mxid,
parent_group, -- parent_id
CASE WHEN EXISTS(SELECT 1 FROM portal_old WHERE jid=parent_group) THEN parent_group ELSE NULL END, -- parent_id
'', -- parent_receiver
CASE WHEN relay_user_id<>'' THEN '' END, -- relay_bridge_id
(SELECT id FROM user_login WHERE user_mxid=relay_user_id), -- relay_login_id
Expand Down Expand Up @@ -198,7 +198,7 @@ SELECT
NULL, -- completed_at
1 -- next_dispatch_min_ts
FROM backfill_queue_old
WHERE type IN (0, 200)
WHERE type IN (0, 200) AND EXISTS(SELECT 1 FROM user_login WHERE user_login.user_mxid=backfill_queue_old.user_mxid)
GROUP BY user_mxid, portal_jid, portal_receiver;

INSERT INTO whatsapp_poll_option_id (bridge_id, msg_mxid, opt_id, opt_hash)
Expand Down

0 comments on commit 4e19e36

Please sign in to comment.