owpengram-server/deploy/migrations/0084_geolive_media_index.up.sql

15 lines
656 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- messages.getRecentLocations 复用共享媒体 seek index避免在 peer 历史上扫描 JSONB。
-- category=10 是服务端内部 geo_live 类别,不暴露给普通 messages.search filter。
INSERT INTO message_box_media (owner_user_id, box_id, peer_id, category, message_date)
SELECT owner_user_id, box_id, peer_id, 10, message_date
FROM message_boxes
WHERE NOT deleted
AND media ->> 'kind' = 'geo_live'
ON CONFLICT DO NOTHING;
INSERT INTO channel_message_media (channel_id, id, category, message_date)
SELECT channel_id, id, 10, message_date
FROM channel_messages
WHERE NOT deleted
AND media ->> 'kind' = 'geo_live'
ON CONFLICT DO NOTHING;