mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-14 03:55:20 +00:00
core: group DAG types (#3286)
* core: group DAG types * fix tests * schema, more types --------- Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c8c17a2f68
commit
7473da36a6
@@ -520,6 +520,52 @@ CREATE TABLE IF NOT EXISTS "received_probes"(
|
||||
created_at TEXT CHECK(created_at NOT NULL),
|
||||
updated_at TEXT CHECK(updated_at NOT NULL)
|
||||
);
|
||||
CREATE TABLE group_events(
|
||||
group_event_id INTEGER PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
|
||||
chat_item_id INTEGER REFERENCES chat_items ON DELETE SET NULL,
|
||||
chat_min_version INTEGER NOT NULL DEFAULT 1, -- chatVRange :: VersionRange
|
||||
chat_max_version INTEGER NOT NULL DEFAULT 1,
|
||||
shared_msg_id BLOB NOT NULL, -- msgId :: SharedMsgId
|
||||
event_data TEXT NOT NULL, -- eventData :: StoredGroupEventData
|
||||
shared_hash BLOB NOT NULL, -- sharedHash :: ByteString
|
||||
event_sent INTEGER NOT NULL, -- 0 for received, 1 for sent; below `rcvd_` fields are null for sent
|
||||
rcvd_author_member_id BLOB, -- ReceivedEventInfo authorMemberId :: MemberId
|
||||
rcvd_author_member_name TEXT, -- ReceivedEventInfo authorMemberName :: ContactName
|
||||
-- ReceivedEventInfo authorMember :: Maybe GroupMemberRef; can be null even for received event
|
||||
rcvd_author_group_member_id INTEGER REFERENCES group_members ON DELETE SET NULL,
|
||||
rcvd_author_contact_profile_id INTEGER REFERENCES contact_profiles ON DELETE SET NULL,
|
||||
-- rcvd_author_role TEXT NOT NULL, -- ReceivedFromRole - store in case it changes?
|
||||
-- ReceivedEventInfo receivedFrom :: GroupMemberRef
|
||||
rcvd_from_group_member_id INTEGER REFERENCES group_members ON DELETE SET NULL,
|
||||
rcvd_from_contact_profile_id INTEGER REFERENCES contact_profiles ON DELETE SET NULL,
|
||||
rcvd_processing TEXT NOT NULL, -- ReceivedEventInfo processing :: EventProcessing
|
||||
rcvd_processed INTEGER NOT NULL DEFAULT 0, -- 1 for processed; when retrieving unprocessed
|
||||
-- rcvd_scheduled_at TEXT, -- EPScheduled UTCTime; when retrieving scheduled at near time?
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
|
||||
);
|
||||
CREATE TABLE group_events_availabilities(
|
||||
group_events_availability_id INTEGER PRIMARY KEY,
|
||||
group_event_id INTEGER NOT NULL REFERENCES group_events ON DELETE CASCADE,
|
||||
available_at_group_member_id INTEGER REFERENCES group_members ON DELETE CASCADE,
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
|
||||
);
|
||||
CREATE TABLE group_events_dag_errors(
|
||||
group_event_dag_error_id INTEGER PRIMARY KEY,
|
||||
group_event_id INTEGER NOT NULL REFERENCES group_events ON DELETE CASCADE,
|
||||
dag_error TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
|
||||
);
|
||||
CREATE TABLE group_events_parents(
|
||||
group_event_parent_id INTEGER NOT NULL REFERENCES group_events ON DELETE CASCADE,
|
||||
group_event_child_id INTEGER NOT NULL REFERENCES group_events ON DELETE CASCADE,
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
UNIQUE(group_event_parent_id, group_event_child_id)
|
||||
);
|
||||
CREATE INDEX contact_profiles_index ON contact_profiles(
|
||||
display_name,
|
||||
full_name
|
||||
@@ -748,3 +794,32 @@ CREATE INDEX idx_connections_via_contact_uri_hash ON connections(
|
||||
user_id,
|
||||
via_contact_uri_hash
|
||||
);
|
||||
CREATE INDEX idx_group_events_user_id ON group_events(user_id);
|
||||
CREATE INDEX idx_group_events_chat_item_id ON group_events(chat_item_id);
|
||||
CREATE INDEX idx_group_events_rcvd_author_group_member_id ON group_events(
|
||||
rcvd_author_group_member_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_rcvd_author_contact_profile_id ON group_events(
|
||||
rcvd_author_contact_profile_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_rcvd_from_group_member_id ON group_events(
|
||||
rcvd_from_group_member_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_rcvd_from_contact_profile_id ON group_events(
|
||||
rcvd_from_contact_profile_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_availabilities_group_event_id ON group_events_availabilities(
|
||||
group_event_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_availabilities_available_at_group_member_id ON group_events_availabilities(
|
||||
available_at_group_member_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_dag_errors_group_event_id ON group_events_dag_errors(
|
||||
group_event_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_parents_group_event_parent_id ON group_events_parents(
|
||||
group_event_parent_id
|
||||
);
|
||||
CREATE INDEX idx_group_events_parents_group_event_child_id ON group_events_parents(
|
||||
group_event_child_id
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user