migration.scripts: add attachments.{channel, message}_id

- schema.sql: remove message_attachments table

    it is uneeded since we have the columns in attachments
This commit is contained in:
Luna 2018-12-08 23:21:11 -03:00
parent 9ecc3d9e7e
commit e885bf859c
2 changed files with 8 additions and 15 deletions

View File

@ -1,6 +1,9 @@
CREATE TABLE IF NOT EXISTS attachments ( CREATE TABLE IF NOT EXISTS attachments (
id bigint PRIMARY KEY, id bigint PRIMARY KEY,
channel_id bigint REFERENCES channels (id),
message_id bigint REFERENCES messages (id),
filename text NOT NULL, filename text NOT NULL,
filesize integer, filesize integer,
@ -10,12 +13,3 @@ CREATE TABLE IF NOT EXISTS attachments (
height integer DEFAULT NULL, height integer DEFAULT NULL,
width integer DEFAULT NULL width integer DEFAULT NULL
); );
-- recreate the attachments table since
-- its been always error'ing since some migrations ago.
CREATE TABLE IF NOT EXISTS message_attachments (
message_id bigint REFERENCES messages (id),
attachment bigint REFERENCES attachments (id),
PRIMARY KEY (message_id, attachment)
);

View File

@ -56,6 +56,11 @@ CREATE TABLE IF NOT EXISTS instance_invites (
CREATE TABLE IF NOT EXISTS attachments ( CREATE TABLE IF NOT EXISTS attachments (
id bigint PRIMARY KEY, id bigint PRIMARY KEY,
-- keeping channel_id and message_id
-- make a way "better" attachment url.
channel_id bigint REFERENCES channels (id),
message_id bigint REFERENCES messages (id),
filename text NOT NULL, filename text NOT NULL,
filesize integer, filesize integer,
@ -634,12 +639,6 @@ CREATE TABLE IF NOT EXISTS messages (
message_type int NOT NULL message_type int NOT NULL
); );
CREATE TABLE IF NOT EXISTS message_attachments (
message_id bigint REFERENCES messages (id),
attachment bigint REFERENCES attachments (id),
PRIMARY KEY (message_id, attachment)
);
CREATE TABLE IF NOT EXISTS message_reactions ( CREATE TABLE IF NOT EXISTS message_reactions (
message_id bigint REFERENCES messages (id), message_id bigint REFERENCES messages (id),
user_id bigint REFERENCES users (id), user_id bigint REFERENCES users (id),