From 89f20b0ff36c8413adc2aa9e3c5226ae2eed2101 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 3 Feb 2023 06:39:25 +0300 Subject: messages_txt -> messages --- src/main/resources/db/migration/V1.43__merge_messages_txt.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/resources/db/migration/V1.43__merge_messages_txt.sql (limited to 'src/main/resources/db') diff --git a/src/main/resources/db/migration/V1.43__merge_messages_txt.sql b/src/main/resources/db/migration/V1.43__merge_messages_txt.sql new file mode 100644 index 00000000..fb43420d --- /dev/null +++ b/src/main/resources/db/migration/V1.43__merge_messages_txt.sql @@ -0,0 +1,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 \ No newline at end of file -- cgit v1.2.3