mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-22 17:31:55 +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:
1 parent
7b7471207a
commit
7726522e5a
12 files changed
+2886
-14
No files matched your search
@@ -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
@@ -568,7 +568,7 @@ updateUserAddressSettings db userContactLinkId AddressSettings {businessAddress,
|
||||
SET auto_accept = ?, auto_accept_incognito = ?, business_address = ?, auto_reply_msg_content = ?
|
||||
WHERE user_contact_link_id = ?
|
||||
|]
|
||||
(autoAcceptValues :. (businessAddress, autoReply, userContactLinkId))
|
||||
(autoAcceptValues :. (BI businessAddress, autoReply, userContactLinkId))
|
||||
where
|
||||
autoAcceptValues = case autoAccept of
|
||||
Just AutoAccept {acceptIncognito} -> (BI True, BI acceptIncognito)
|
||||
|
||||
@@ -25,6 +25,7 @@ ALTER TABLE group_members ADD COLUMN member_xcontact_id BLOB;
|
||||
ALTER TABLE group_members ADD COLUMN member_welcome_shared_msg_id BLOB;
|
||||
|
||||
ALTER TABLE user_contact_links ADD COLUMN short_link_data_set INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE user_contact_links ADD COLUMN short_link_large_data_set INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE groups ADD COLUMN conn_full_link_to_connect BLOB;
|
||||
ALTER TABLE groups ADD COLUMN conn_short_link_to_connect BLOB;
|
||||
@@ -55,6 +56,7 @@ ALTER TABLE group_members DROP COLUMN member_xcontact_id;
|
||||
ALTER TABLE group_members DROP COLUMN member_welcome_shared_msg_id;
|
||||
|
||||
ALTER TABLE user_contact_links DROP COLUMN short_link_data_set;
|
||||
ALTER TABLE user_contact_links DROP COLUMN short_link_large_data_set;
|
||||
|
||||
ALTER TABLE groups DROP COLUMN conn_full_link_to_connect;
|
||||
ALTER TABLE groups DROP COLUMN conn_short_link_to_connect;
|
||||
|
||||
@@ -339,6 +339,7 @@ CREATE TABLE user_contact_links(
|
||||
business_address INTEGER DEFAULT 0,
|
||||
short_link_contact BLOB,
|
||||
short_link_data_set INTEGER NOT NULL DEFAULT 0,
|
||||
short_link_large_data_set INTEGER NOT NULL DEFAULT 0,
|
||||
UNIQUE(user_id, local_display_name)
|
||||
);
|
||||
CREATE TABLE contact_requests(
|
||||
|
||||
Reference in new issue
Block a user