From d5ad4bb96d275f6d72ddc54d12fcb2d974cc171f Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 8 Dec 2018 22:08:37 -0300 Subject: [PATCH] migration.scripts: add 10_add_attachments_table - schema.sql: add attachments table --- .../scripts/10_add_attachments_table.sql | 21 +++++++++++++++++++ schema.sql | 15 +++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 manage/cmd/migration/scripts/10_add_attachments_table.sql diff --git a/manage/cmd/migration/scripts/10_add_attachments_table.sql b/manage/cmd/migration/scripts/10_add_attachments_table.sql new file mode 100644 index 0000000..cd2f634 --- /dev/null +++ b/manage/cmd/migration/scripts/10_add_attachments_table.sql @@ -0,0 +1,21 @@ +CREATE TABLE IF NOT EXISTS attachments ( + id bigint PRIMARY KEY, + + filename text NOT NULL, + filesize integer, + + image boolean DEFAULT FALSE, + + -- only not null if image=true + height 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) +); + diff --git a/schema.sql b/schema.sql index e3df14d..387a13f 100644 --- a/schema.sql +++ b/schema.sql @@ -52,6 +52,21 @@ CREATE TABLE IF NOT EXISTS instance_invites ( ); +-- main attachments table +CREATE TABLE IF NOT EXISTS attachments ( + id bigint PRIMARY KEY, + + filename text NOT NULL, + filesize integer, + + image boolean DEFAULT FALSE, + + -- only not null if image=true + height integer DEFAULT NULL, + width integer DEFAULT NULL, +); + + CREATE TABLE IF NOT EXISTS icons ( -- can be 'user', 'guild', 'emoji' scope text NOT NULL,