Private
Public Access
1
0

Don't overwrite already resolved participants, better naming of keys

This commit is contained in:
2025-06-26 18:23:15 -07:00
parent bb19db17cd
commit f6bb1a9b57
25 changed files with 263 additions and 306 deletions

View File

@@ -0,0 +1,46 @@
-- Your SQL goes here
CREATE TABLE `messages`(
`id` TEXT NOT NULL PRIMARY KEY,
`text` TEXT NOT NULL,
`sender_participant_handle` TEXT,
`date` TIMESTAMP NOT NULL,
`file_transfer_guids` TEXT,
`attachment_metadata` TEXT,
FOREIGN KEY (`sender_participant_handle`) REFERENCES `participants`(`handle`)
);
CREATE TABLE `conversation_messages`(
`conversation_id` TEXT NOT NULL,
`message_id` TEXT NOT NULL,
PRIMARY KEY(`conversation_id`, `message_id`),
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`),
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`)
);
CREATE TABLE `settings`(
`key` TEXT NOT NULL PRIMARY KEY,
`value` BINARY NOT NULL
);
CREATE TABLE `conversations`(
`id` TEXT NOT NULL PRIMARY KEY,
`unread_count` BIGINT NOT NULL,
`display_name` TEXT,
`last_message_preview` TEXT,
`date` TIMESTAMP NOT NULL
);
CREATE TABLE `participants`(
`handle` TEXT NOT NULL PRIMARY KEY,
`is_me` BOOL NOT NULL,
`contact_id` TEXT
);
CREATE TABLE `conversation_participants`(
`conversation_id` TEXT NOT NULL,
`participant_handle` TEXT NOT NULL,
PRIMARY KEY(`conversation_id`, `participant_handle`),
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`),
FOREIGN KEY (`participant_handle`) REFERENCES `participants`(`handle`)
);