From b75becd960b01811de79530232d7e4d0de1d94ba Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 11 Jul 2018 20:13:20 +0200 Subject: [PATCH] Add pointer from chan to the last msg, add messages_queue table --- .../schema/mysql/20180704080000.base.up.sql | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sam/db/schema/mysql/20180704080000.base.up.sql b/sam/db/schema/mysql/20180704080000.base.up.sql index 02fc0aa3c..ac638b985 100644 --- a/sam/db/schema/mysql/20180704080000.base.up.sql +++ b/sam/db/schema/mysql/20180704080000.base.up.sql @@ -25,12 +25,14 @@ CREATE TABLE teams ( -- Keeps all known channels CREATE TABLE channels ( id BIGINT UNSIGNED NOT NULL, - label TEXT NOT NULL, -- display name of the channel + name TEXT NOT NULL, -- display name of the channel meta JSON NOT NULL, archived_at DATETIME NULL, deleted_at DATETIME NULL, -- channel soft delete + rel_last_message BIGINT UNSIGNED, + PRIMARY KEY (id) ); @@ -102,6 +104,19 @@ CREATE TABLE messages ( ); +-- temp copy of messages (when they are pushed to the primary organisation, row gets removed) +CREATE TABLE messages_queue ( + id BIGINT UNSIGNED NOT NULL, + mimetype VARCHAR(255) NULL, + body TEXT NULL, + rel_user BIGINT UNSIGNED NOT NULL REFERENCES users(id), + rel_channel BIGINT UNSIGNED NOT NULL REFERENCES channels(id), + rel_message BIGINT UNSIGNED NOT NULL REFERENCES messages(id), + + PRIMARY KEY (id) +); + + CREATE TABLE channel_views ( rel_channel BIGINT UNSIGNED NOT NULL REFERENCES channels(id), rel_user BIGINT UNSIGNED NOT NULL REFERENCES users(id), @@ -113,4 +128,4 @@ CREATE TABLE channel_views ( new_since INT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (rel_user, rel_channel) -); \ No newline at end of file +);