mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-04 03:51:48 +00:00
core: sync connections (#6345)
* core: sync subsbriptions * sha map * sync event * should delete flag * wip * schema * wip * delete * update simplexmq * plans * rename, adapt * update * plans * option to show ids * plans * fix, test * more tests * postgres * plans * cleanup * plans --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20250802_chat_peer_type
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250813_delivery_tasks
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250919_group_summary
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250922_remove_unused_connections
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20251007_connections_sync
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
@@ -37,7 +38,8 @@ schemaMigrations =
|
||||
("20250802_chat_peer_type", m20250802_chat_peer_type, Just down_m20250802_chat_peer_type),
|
||||
("20250813_delivery_tasks", m20250813_delivery_tasks, Just down_m20250813_delivery_tasks),
|
||||
("20250919_group_summary", m20250919_group_summary, Just down_m20250919_group_summary),
|
||||
("20250922_remove_unused_connections", m20250922_remove_unused_connections, Just down_m20250922_remove_unused_connections)
|
||||
("20250922_remove_unused_connections", m20250922_remove_unused_connections, Just down_m20250922_remove_unused_connections),
|
||||
("20251007_connections_sync", m20251007_connections_sync, Just down_m20251007_connections_sync)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20251007_connections_sync where
|
||||
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20251007_connections_sync :: Text
|
||||
m20251007_connections_sync =
|
||||
T.pack
|
||||
[r|
|
||||
CREATE TABLE connections_sync(
|
||||
connections_sync_id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
should_sync SMALLINT NOT NULL DEFAULT 0,
|
||||
last_sync_ts TIMESTAMPTZ
|
||||
);
|
||||
|
||||
INSERT INTO connections_sync (connections_sync_id, should_sync, last_sync_ts) VALUES (1,0,NULL);
|
||||
|]
|
||||
|
||||
down_m20251007_connections_sync :: Text
|
||||
down_m20251007_connections_sync =
|
||||
T.pack
|
||||
[r|
|
||||
DROP TABLE connections_sync;
|
||||
|]
|
||||
@@ -390,6 +390,25 @@ ALTER TABLE test_chat_schema.connections ALTER COLUMN connection_id ADD GENERATE
|
||||
|
||||
|
||||
|
||||
CREATE TABLE test_chat_schema.connections_sync (
|
||||
connections_sync_id bigint NOT NULL,
|
||||
should_sync smallint DEFAULT 0 NOT NULL,
|
||||
last_sync_ts timestamp with time zone
|
||||
);
|
||||
|
||||
|
||||
|
||||
ALTER TABLE test_chat_schema.connections_sync ALTER COLUMN connections_sync_id ADD GENERATED BY DEFAULT AS IDENTITY (
|
||||
SEQUENCE NAME test_chat_schema.connections_sync_connections_sync_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1
|
||||
);
|
||||
|
||||
|
||||
|
||||
CREATE TABLE test_chat_schema.contact_profiles (
|
||||
contact_profile_id bigint NOT NULL,
|
||||
display_name text NOT NULL,
|
||||
@@ -1358,6 +1377,11 @@ ALTER TABLE ONLY test_chat_schema.connections
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.connections_sync
|
||||
ADD CONSTRAINT connections_sync_pkey PRIMARY KEY (connections_sync_id);
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.contact_profiles
|
||||
ADD CONSTRAINT contact_profiles_pkey PRIMARY KEY (contact_profile_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user