mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-25 17:44:38 +00:00
core: postgres migration for short links, postgres schema dump, fix query to be compatible (#6025)
* core: postgres migration for short links, postgres schema dump, fix query to be compatible * rename fields
This commit is contained in:
@@ -8,6 +8,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20241220_initial
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250402_short_links
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250512_member_admission
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250513_group_scope
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250526_short_links
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
@@ -15,7 +16,8 @@ schemaMigrations =
|
||||
[ ("20241220_initial", m20241220_initial, Nothing),
|
||||
("20250402_short_links", m20250402_short_links, Just down_m20250402_short_links),
|
||||
("20250512_member_admission", m20250512_member_admission, Just down_m20250512_member_admission),
|
||||
("20250513_group_scope", m20250513_group_scope, Just down_m20250513_group_scope)
|
||||
("20250513_group_scope", m20250513_group_scope, Just down_m20250513_group_scope),
|
||||
("20250526_short_links", m20250526_short_links, Just down_m20250526_short_links)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20250526_short_links where
|
||||
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20250526_short_links :: Text
|
||||
m20250526_short_links =
|
||||
T.pack
|
||||
[r|
|
||||
ALTER TABLE contacts
|
||||
ADD COLUMN conn_full_link_to_connect BYTEA,
|
||||
ADD COLUMN conn_short_link_to_connect BYTEA,
|
||||
ADD COLUMN welcome_shared_msg_id BYTEA,
|
||||
ADD COLUMN request_shared_msg_id BYTEA,
|
||||
ADD COLUMN contact_request_id BIGINT REFERENCES contact_requests ON DELETE SET NULL;
|
||||
CREATE INDEX idx_contacts_contact_request_id ON contacts(contact_request_id);
|
||||
|
||||
ALTER TABLE contact_requests
|
||||
ADD COLUMN business_group_id BIGINT REFERENCES groups(group_id) ON DELETE CASCADE,
|
||||
ADD COLUMN welcome_shared_msg_id BYTEA,
|
||||
ADD COLUMN request_shared_msg_id BYTEA;
|
||||
CREATE INDEX idx_contact_requests_business_group_id ON contact_requests(business_group_id);
|
||||
|
||||
ALTER TABLE group_members
|
||||
ADD COLUMN member_xcontact_id BYTEA,
|
||||
ADD COLUMN member_welcome_shared_msg_id BYTEA;
|
||||
|
||||
ALTER TABLE user_contact_links
|
||||
ADD COLUMN short_link_data_set SMALLINT NOT NULL DEFAULT 0,
|
||||
ADD COLUMN short_link_large_data_set SMALLINT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE groups
|
||||
ADD COLUMN conn_full_link_to_connect BYTEA,
|
||||
ADD COLUMN conn_short_link_to_connect BYTEA,
|
||||
ADD COLUMN conn_link_started_connection SMALLINT NOT NULL DEFAULT 0,
|
||||
ADD COLUMN welcome_shared_msg_id BYTEA,
|
||||
ADD COLUMN request_shared_msg_id BYTEA;
|
||||
|
||||
ALTER TABLE chat_items ADD COLUMN show_group_as_sender SMALLINT NOT NULL DEFAULT 0;
|
||||
|]
|
||||
|
||||
down_m20250526_short_links :: Text
|
||||
down_m20250526_short_links =
|
||||
T.pack
|
||||
[r|
|
||||
DROP INDEX idx_contacts_contact_request_id;
|
||||
|
||||
ALTER TABLE contacts
|
||||
DROP COLUMN conn_full_link_to_connect,
|
||||
DROP COLUMN conn_short_link_to_connect,
|
||||
DROP COLUMN welcome_shared_msg_id,
|
||||
DROP COLUMN request_shared_msg_id,
|
||||
DROP COLUMN contact_request_id;
|
||||
|
||||
DROP INDEX idx_contact_requests_business_group_id;
|
||||
|
||||
ALTER TABLE contact_requests
|
||||
DROP COLUMN business_group_id,
|
||||
DROP COLUMN welcome_shared_msg_id,
|
||||
DROP COLUMN request_shared_msg_id;
|
||||
|
||||
ALTER TABLE group_members
|
||||
DROP COLUMN member_xcontact_id,
|
||||
DROP COLUMN member_welcome_shared_msg_id;
|
||||
|
||||
ALTER TABLE user_contact_links
|
||||
DROP COLUMN short_link_data_set,
|
||||
DROP COLUMN short_link_large_data_set;
|
||||
|
||||
ALTER TABLE groups
|
||||
DROP COLUMN conn_full_link_to_connect,
|
||||
DROP COLUMN conn_short_link_to_connect,
|
||||
DROP COLUMN conn_link_started_connection,
|
||||
DROP COLUMN welcome_shared_msg_id,
|
||||
DROP COLUMN request_shared_msg_id;
|
||||
|
||||
ALTER TABLE chat_items DROP COLUMN show_group_as_sender;
|
||||
|]
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user