Files
Ydisks-Xianyu-Helper/internal/db/migrations/postgres/00025_chat_direction_repair.sql
T
Christ 67d7214930 feat: add account automation and isolated chat
- add account-level auto rating and daily polish tasks\n- add cached historical chat, media, emoji, and per-account realtime sync\n- add SQLite, MySQL, and PostgreSQL migrations and regression coverage\n- align account, sidebar, and chat interfaces with the new workflows
2026-08-08 22:16:35 +08:00

13 lines
470 B
SQL

-- +goose Up
UPDATE chat_messages SET direction='outgoing', sender_name='我'
WHERE sender_id=cookie_id AND direction='incoming';
UPDATE chat_sessions cs SET buyer_id=COALESCE((
SELECT m.sender_id FROM chat_messages m
WHERE m.cookie_id=cs.cookie_id AND m.chat_id=cs.chat_id
AND m.direction='incoming' AND m.sender_id<>cs.cookie_id
ORDER BY m.sent_at DESC,m.id DESC LIMIT 1
), cs.buyer_id);
-- +goose Down
-- Data repair is intentionally irreversible.