Don't overwrite already resolved participants, better naming of keys
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE `conversation_participants`(
|
||||
`conversation_id` TEXT NOT NULL,
|
||||
`participant_id` INTEGER NOT NULL,
|
||||
PRIMARY KEY(`conversation_id`, `participant_id`)
|
||||
);
|
||||
|
||||
CREATE TABLE `messages`(
|
||||
`id` TEXT NOT NULL PRIMARY KEY,
|
||||
`text` TEXT NOT NULL,
|
||||
`sender_participant_id` INTEGER,
|
||||
`date` TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `conversation_messages`(
|
||||
`conversation_id` TEXT NOT NULL,
|
||||
`message_id` TEXT NOT NULL,
|
||||
PRIMARY KEY(`conversation_id`, `message_id`)
|
||||
);
|
||||
|
||||
CREATE TABLE `participants`(
|
||||
`id` INTEGER NOT NULL PRIMARY KEY,
|
||||
`display_name` TEXT,
|
||||
`is_me` BOOL 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
|
||||
);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `settings`;
|
||||
@@ -1,11 +0,0 @@
|
||||
-- Your SQL goes here
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE `settings`(
|
||||
`key` TEXT NOT NULL PRIMARY KEY,
|
||||
`value` BINARY NOT NULL
|
||||
);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Remove attachment_metadata column from messages table
|
||||
ALTER TABLE messages DROP COLUMN attachment_metadata;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Add attachment_metadata column to messages table
|
||||
ALTER TABLE messages ADD COLUMN attachment_metadata TEXT;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Remove file_transfer_guids column from messages table
|
||||
ALTER TABLE messages DROP COLUMN file_transfer_guids;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Add file_transfer_guids column to messages table
|
||||
ALTER TABLE messages ADD COLUMN file_transfer_guids TEXT;
|
||||
@@ -1,14 +0,0 @@
|
||||
-- Revert participants table to remove contact_id column
|
||||
-- SQLite does not support DROP COLUMN directly, so we recreate the table without contact_id
|
||||
PRAGMA foreign_keys=off;
|
||||
CREATE TABLE participants_backup (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
display_name TEXT,
|
||||
is_me BOOL NOT NULL
|
||||
);
|
||||
INSERT INTO participants_backup (id, display_name, is_me)
|
||||
SELECT id, display_name, is_me
|
||||
FROM participants;
|
||||
DROP TABLE participants;
|
||||
ALTER TABLE participants_backup RENAME TO participants;
|
||||
PRAGMA foreign_keys=on;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Add contact_id column to participants to store an external contact identifier (e.g., Folks ID)
|
||||
ALTER TABLE participants ADD COLUMN contact_id TEXT;
|
||||
@@ -1,6 +1,7 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE IF EXISTS `conversation_participants`;
|
||||
DROP TABLE IF EXISTS `messages`;
|
||||
DROP TABLE IF EXISTS `conversation_messages`;
|
||||
DROP TABLE IF EXISTS `participants`;
|
||||
DROP TABLE IF EXISTS `settings`;
|
||||
DROP TABLE IF EXISTS `conversations`;
|
||||
DROP TABLE IF EXISTS `participants`;
|
||||
DROP TABLE IF EXISTS `conversation_participants`;
|
||||
@@ -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`)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user