0_base.sql: fix ordering of table creations

fixes attachments table being created BEFORE its foreign keys
This commit is contained in:
Luna 2019-04-04 00:30:59 -03:00
parent bb542550b8
commit 6ba9b07381
1 changed files with 20 additions and 18 deletions

View File

@ -42,24 +42,6 @@ CREATE TABLE IF NOT EXISTS instance_invites (
);
-- main attachments table
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,
image boolean DEFAULT FALSE,
-- only not null if image=true
height integer DEFAULT NULL,
width integer DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS icons (
@ -693,3 +675,23 @@ CREATE TABLE IF NOT EXISTS channel_pins (
message_id bigint REFERENCES messages (id) ON DELETE CASCADE,
PRIMARY KEY (channel_id, message_id)
);
-- main attachments table
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,
image boolean DEFAULT FALSE,
-- only not null if image=true
height integer DEFAULT NULL,
width integer DEFAULT NULL
);