diff --git a/manage/cmd/migration/scripts/10_add_attachments_table.sql b/manage/cmd/migration/scripts/10_add_attachments_table.sql index cd2f634..b1f979d 100644 --- a/manage/cmd/migration/scripts/10_add_attachments_table.sql +++ b/manage/cmd/migration/scripts/10_add_attachments_table.sql @@ -1,6 +1,9 @@ CREATE TABLE IF NOT EXISTS attachments ( id bigint PRIMARY KEY, + channel_id bigint REFERENCES channels (id), + message_id bigint REFERENCES messages (id), + filename text NOT NULL, filesize integer, @@ -10,12 +13,3 @@ CREATE TABLE IF NOT EXISTS attachments ( 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 387a13f..72d68e1 100644 --- a/schema.sql +++ b/schema.sql @@ -56,6 +56,11 @@ CREATE TABLE IF NOT EXISTS instance_invites ( CREATE TABLE IF NOT EXISTS attachments ( 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, filesize integer, @@ -634,12 +639,6 @@ CREATE TABLE IF NOT EXISTS messages ( 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 ( message_id bigint REFERENCES messages (id), user_id bigint REFERENCES users (id),