mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-03 02:31:50 +00:00
chat: add simplex_name to contact_profiles and group_profiles
Adds nullable simplex_name TEXT column and partial UNIQUE (user_id, simplex_name) index to both contact_profiles and group_profiles tables. Distinct from contacts.simplex_name / groups.simplex_name (M20260603), which carry the user's locally-known label set by the prepare-via-name path; the new columns will carry the peer's broadcast claim received via XInfo / XGrpInfo (wired up in following commits).
This commit is contained in:
@@ -138,6 +138,7 @@ library
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260530_client_services
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260531_member_removed_at
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260603_simplex_name
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260604_simplex_name_profiles
|
||||
else
|
||||
exposed-modules:
|
||||
Simplex.Chat.Archive
|
||||
@@ -298,6 +299,7 @@ library
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260530_client_services
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260531_member_removed_at
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260603_simplex_name
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260604_simplex_name_profiles
|
||||
other-modules:
|
||||
Paths_simplex_chat
|
||||
hs-source-dirs:
|
||||
|
||||
@@ -36,6 +36,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20260529_delivery_job_senders
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260530_client_services
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260531_member_removed_at
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260603_simplex_name
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260604_simplex_name_profiles
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
@@ -71,7 +72,8 @@ schemaMigrations =
|
||||
("20260529_delivery_job_senders", m20260529_delivery_job_senders, Just down_m20260529_delivery_job_senders),
|
||||
("20260530_client_services", m20260530_client_services, Just down_m20260530_client_services),
|
||||
("20260531_member_removed_at", m20260531_member_removed_at, Just down_m20260531_member_removed_at),
|
||||
("20260603_simplex_name", m20260603_simplex_name, Just down_m20260603_simplex_name)
|
||||
("20260603_simplex_name", m20260603_simplex_name, Just down_m20260603_simplex_name),
|
||||
("20260604_simplex_name_profiles", m20260604_simplex_name_profiles, Just down_m20260604_simplex_name_profiles)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260604_simplex_name_profiles where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20260604_simplex_name_profiles :: Text
|
||||
m20260604_simplex_name_profiles =
|
||||
[r|
|
||||
ALTER TABLE contact_profiles ADD COLUMN simplex_name TEXT;
|
||||
ALTER TABLE group_profiles ADD COLUMN simplex_name TEXT;
|
||||
|
||||
CREATE UNIQUE INDEX idx_contact_profiles_simplex_name
|
||||
ON contact_profiles(user_id, simplex_name)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
|
||||
CREATE UNIQUE INDEX idx_group_profiles_simplex_name
|
||||
ON group_profiles(user_id, simplex_name)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
|]
|
||||
|
||||
down_m20260604_simplex_name_profiles :: Text
|
||||
down_m20260604_simplex_name_profiles =
|
||||
[r|
|
||||
DROP INDEX idx_group_profiles_simplex_name;
|
||||
DROP INDEX idx_contact_profiles_simplex_name;
|
||||
|
||||
ALTER TABLE group_profiles DROP COLUMN simplex_name;
|
||||
ALTER TABLE contact_profiles DROP COLUMN simplex_name;
|
||||
|]
|
||||
@@ -532,7 +532,8 @@ CREATE TABLE test_chat_schema.contact_profiles (
|
||||
preferences text,
|
||||
contact_link bytea,
|
||||
short_descr text,
|
||||
chat_peer_type text
|
||||
chat_peer_type text,
|
||||
simplex_name text
|
||||
);
|
||||
|
||||
|
||||
@@ -856,7 +857,8 @@ CREATE TABLE test_chat_schema.group_profiles (
|
||||
group_web_page text,
|
||||
group_domain text,
|
||||
domain_web_page bigint,
|
||||
allow_embedding bigint
|
||||
allow_embedding bigint,
|
||||
simplex_name text
|
||||
);
|
||||
|
||||
|
||||
@@ -2137,6 +2139,10 @@ CREATE INDEX idx_contact_profiles_contact_link ON test_chat_schema.contact_profi
|
||||
|
||||
|
||||
|
||||
CREATE UNIQUE INDEX idx_contact_profiles_simplex_name ON test_chat_schema.contact_profiles USING btree (user_id, simplex_name) WHERE (simplex_name IS NOT NULL);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_contact_profiles_user_id ON test_chat_schema.contact_profiles USING btree (user_id);
|
||||
|
||||
|
||||
@@ -2321,6 +2327,10 @@ CREATE INDEX idx_group_members_user_id_local_display_name ON test_chat_schema.gr
|
||||
|
||||
|
||||
|
||||
CREATE UNIQUE INDEX idx_group_profiles_simplex_name ON test_chat_schema.group_profiles USING btree (user_id, simplex_name) WHERE (simplex_name IS NOT NULL);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_group_profiles_user_id ON test_chat_schema.group_profiles USING btree (user_id);
|
||||
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@ import Simplex.Chat.Store.SQLite.Migrations.M20260529_delivery_job_senders
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260530_client_services
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260531_member_removed_at
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260603_simplex_name
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260604_simplex_name_profiles
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Query, Maybe Query)]
|
||||
@@ -317,7 +318,8 @@ schemaMigrations =
|
||||
("20260529_delivery_job_senders", m20260529_delivery_job_senders, Just down_m20260529_delivery_job_senders),
|
||||
("20260530_client_services", m20260530_client_services, Just down_m20260530_client_services),
|
||||
("20260531_member_removed_at", m20260531_member_removed_at, Just down_m20260531_member_removed_at),
|
||||
("20260603_simplex_name", m20260603_simplex_name, Just down_m20260603_simplex_name)
|
||||
("20260603_simplex_name", m20260603_simplex_name, Just down_m20260603_simplex_name),
|
||||
("20260604_simplex_name_profiles", m20260604_simplex_name_profiles, Just down_m20260604_simplex_name_profiles)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.SQLite.Migrations.M20260604_simplex_name_profiles where
|
||||
|
||||
import Database.SQLite.Simple (Query)
|
||||
import Database.SQLite.Simple.QQ (sql)
|
||||
|
||||
m20260604_simplex_name_profiles :: Query
|
||||
m20260604_simplex_name_profiles =
|
||||
[sql|
|
||||
ALTER TABLE contact_profiles ADD COLUMN simplex_name TEXT;
|
||||
ALTER TABLE group_profiles ADD COLUMN simplex_name TEXT;
|
||||
|
||||
CREATE UNIQUE INDEX idx_contact_profiles_simplex_name
|
||||
ON contact_profiles(user_id, simplex_name)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
|
||||
CREATE UNIQUE INDEX idx_group_profiles_simplex_name
|
||||
ON group_profiles(user_id, simplex_name)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
|]
|
||||
|
||||
down_m20260604_simplex_name_profiles :: Query
|
||||
down_m20260604_simplex_name_profiles =
|
||||
[sql|
|
||||
DROP INDEX idx_group_profiles_simplex_name;
|
||||
DROP INDEX idx_contact_profiles_simplex_name;
|
||||
|
||||
ALTER TABLE group_profiles DROP COLUMN simplex_name;
|
||||
ALTER TABLE contact_profiles DROP COLUMN simplex_name;
|
||||
|]
|
||||
@@ -19,7 +19,8 @@ CREATE TABLE contact_profiles(
|
||||
preferences TEXT,
|
||||
contact_link BLOB,
|
||||
short_descr TEXT,
|
||||
chat_peer_type TEXT
|
||||
chat_peer_type TEXT,
|
||||
simplex_name TEXT
|
||||
) STRICT;
|
||||
CREATE TABLE users(
|
||||
user_id INTEGER PRIMARY KEY,
|
||||
@@ -131,7 +132,8 @@ CREATE TABLE group_profiles(
|
||||
group_web_page TEXT,
|
||||
group_domain TEXT,
|
||||
domain_web_page INTEGER,
|
||||
allow_embedding INTEGER
|
||||
allow_embedding INTEGER,
|
||||
simplex_name TEXT
|
||||
) STRICT;
|
||||
CREATE TABLE groups(
|
||||
group_id INTEGER PRIMARY KEY, -- local group ID
|
||||
@@ -1322,6 +1324,18 @@ ON groups(
|
||||
simplex_name
|
||||
)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
CREATE UNIQUE INDEX idx_contact_profiles_simplex_name
|
||||
ON contact_profiles(
|
||||
user_id,
|
||||
simplex_name
|
||||
)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
CREATE UNIQUE INDEX idx_group_profiles_simplex_name
|
||||
ON group_profiles(
|
||||
user_id,
|
||||
simplex_name
|
||||
)
|
||||
WHERE simplex_name IS NOT NULL;
|
||||
CREATE TRIGGER on_group_members_insert_update_summary
|
||||
AFTER INSERT ON group_members
|
||||
FOR EACH ROW
|
||||
|
||||
Reference in New Issue
Block a user