aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/db/migration/V1.43__merge_messages_txt.sql
blob: fb43420de4778440d04e2d60404d3a59028b0c52 (plain) (blame)
1
2
3
4
5
6
7
8
ALTER TABLE messages ADD COLUMN txt TEXT;
ALTER TABLE messages ADD COLUMN repliesby TEXT;
ALTER TABLE messages ADD COLUMN updated_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE replies ALTER updated_at TYPE timestamptz USING updated_at AT TIME ZONE 'UTC';
UPDATE messages
SET txt=m.txt, repliesby=m.repliesby, updated_at=m.updated_at
FROM (SELECT message_id id, txt, repliesby, updated_at AT TIME ZONE 'UTC' updated_at FROM messages_txt) m
WHERE message_id=m.id