mirror of
https://github.com/mautrix/whatsapp.git
synced 2025-03-14 14:15:38 +00:00
legacymigrate: don't migrate backfill tables
They're only used on Beeper anyway because upstream dropped MSC2716 support. Fixes #735 [skip cd]
This commit is contained in:
parent
6cd026fd0d
commit
28f497c0c4
1 changed files with 0 additions and 91 deletions
|
@ -195,101 +195,10 @@ SELECT
|
|||
expire_at * 1000000 -- disappear_at
|
||||
FROM disappearing_message_old;
|
||||
|
||||
INSERT INTO backfill_task (
|
||||
bridge_id, portal_id, portal_receiver, user_login_id, batch_count, is_done,
|
||||
cursor, oldest_message_id, dispatched_at, completed_at, next_dispatch_min_ts
|
||||
)
|
||||
SELECT
|
||||
'', -- bridge_id
|
||||
portal_jid, -- portal_id
|
||||
CASE WHEN portal_receiver LIKE '%@s.whatsapp.net' THEN replace(portal_receiver, '@s.whatsapp.net', '') ELSE '' END, -- portal_receiver
|
||||
(SELECT id FROM user_login WHERE user_login.user_mxid=backfill_queue_old.user_mxid), -- user_login_id
|
||||
COUNT(*), -- batch_count
|
||||
COUNT(*) = COUNT(completed_at), -- is_done
|
||||
'', -- cursor
|
||||
'', -- oldest_message_id
|
||||
-- only: postgres
|
||||
EXTRACT(EPOCH FROM MAX(dispatch_time)) * 1000000000, -- dispatched_at
|
||||
-- only: sqlite (line commented)
|
||||
-- unixepoch(MAX(dispatch_time)) * 1000000000,
|
||||
NULL, -- completed_at
|
||||
1 -- next_dispatch_min_ts
|
||||
FROM backfill_queue_old
|
||||
WHERE type IN (0, 200)
|
||||
AND EXISTS(SELECT 1 FROM user_login WHERE user_login.user_mxid=backfill_queue_old.user_mxid)
|
||||
AND portal_receiver IS NOT NULL
|
||||
GROUP BY user_mxid, portal_jid, portal_receiver;
|
||||
|
||||
INSERT INTO whatsapp_poll_option_id (bridge_id, msg_mxid, opt_id, opt_hash)
|
||||
SELECT '', msg_mxid, opt_id, opt_hash
|
||||
FROM poll_option_id_old;
|
||||
|
||||
INSERT INTO whatsapp_history_sync_conversation (
|
||||
bridge_id, user_login_id, chat_jid, last_message_timestamp, archived, pinned, mute_end_time,
|
||||
end_of_history_transfer_type, ephemeral_expiration, ephemeral_setting_timestamp, marked_as_unread, unread_count
|
||||
)
|
||||
SELECT
|
||||
'',
|
||||
user_login.id,
|
||||
portal_jid,
|
||||
-- only: postgres
|
||||
CAST(EXTRACT(EPOCH FROM last_message_timestamp) AS BIGINT),
|
||||
-- only: sqlite (line commented)
|
||||
-- unixepoch(last_message_timestamp),
|
||||
archived,
|
||||
CASE WHEN pinned > 0 THEN true ELSE false END,
|
||||
-- only: postgres
|
||||
CAST(EXTRACT(EPOCH FROM mute_end_time) AS BIGINT),
|
||||
-- only: sqlite (line commented)
|
||||
-- unixepoch(mute_end_time),
|
||||
end_of_history_transfer_type,
|
||||
ephemeral_expiration,
|
||||
0,
|
||||
marked_as_unread,
|
||||
unread_count
|
||||
FROM history_sync_conversation_old
|
||||
LEFT JOIN user_login ON user_login.user_mxid = history_sync_conversation_old.user_mxid
|
||||
WHERE user_login.id IS NOT NULL;
|
||||
|
||||
INSERT INTO whatsapp_history_sync_message (
|
||||
bridge_id, user_login_id, chat_jid, sender_jid, message_id, timestamp, data, inserted_time
|
||||
)
|
||||
SELECT
|
||||
'',
|
||||
user_login.id,
|
||||
conversation_id,
|
||||
message_id,
|
||||
'',
|
||||
-- only: postgres
|
||||
CAST(EXTRACT(EPOCH FROM timestamp) AS BIGINT),
|
||||
-- only: sqlite (line commented)
|
||||
-- unixepoch(timestamp),
|
||||
data,
|
||||
-- only: postgres
|
||||
CAST(EXTRACT(EPOCH FROM inserted_time) AS BIGINT)
|
||||
-- only: sqlite (line commented)
|
||||
-- unixepoch(inserted_time)
|
||||
FROM history_sync_message_old
|
||||
LEFT JOIN user_login ON user_login.user_mxid = history_sync_message_old.user_mxid
|
||||
WHERE user_login.id IS NOT NULL;
|
||||
|
||||
INSERT INTO whatsapp_media_backfill_request (
|
||||
bridge_id, user_login_id, message_id, portal_id, portal_receiver, media_key, status, error
|
||||
)
|
||||
SELECT
|
||||
'',
|
||||
user_login.id,
|
||||
(SELECT id FROM message WHERE mxid=event_id),
|
||||
portal_jid,
|
||||
CASE WHEN portal_receiver LIKE '%@s.whatsapp.net' THEN replace(portal_receiver, '@s.whatsapp.net', '') ELSE '' END,
|
||||
media_key,
|
||||
status,
|
||||
COALESCE(error, '')
|
||||
FROM media_backfill_requests_old
|
||||
LEFT JOIN user_login ON user_login.user_mxid = media_backfill_requests_old.user_mxid
|
||||
WHERE user_login.id IS NOT NULL AND status IS NOT NULL AND media_key IS NOT NULL AND EXISTS (SELECT 1 FROM message WHERE mxid=event_id)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
DROP TABLE backfill_queue_old;
|
||||
DROP TABLE backfill_state_old;
|
||||
DROP TABLE disappearing_message_old;
|
||||
|
|
Loading…
Add table
Reference in a new issue