2021-08-26 17:50:27 +03:00
|
|
|
-- UP
|
|
|
|
-- Posts
|
|
|
|
CREATE TABLE posts
|
|
|
|
(
|
|
|
|
id SERIAL NOT NULL,
|
2021-08-31 19:27:23 +03:00
|
|
|
|
|
|
|
is_parent BOOLEAN NOT NULL,
|
2021-08-31 22:10:24 +03:00
|
|
|
parent_id INT REFERENCES posts (id) NULL,
|
2021-08-31 19:27:23 +03:00
|
|
|
|
2021-08-31 22:10:24 +03:00
|
|
|
is_deleted BOOLEAN DEFAULT false NOT NULL,
|
2021-08-31 19:27:23 +03:00
|
|
|
|
2021-08-26 17:50:27 +03:00
|
|
|
title VARCHAR NOT NULL,
|
|
|
|
text TEXT NOT NULL,
|
|
|
|
is_sage BOOLEAN NOT NULL,
|
2021-08-31 19:27:23 +03:00
|
|
|
|
2021-08-26 17:50:27 +03:00
|
|
|
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
2021-08-31 19:27:23 +03:00
|
|
|
updated_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (id)
|
2021-08-26 17:50:27 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- Files
|
|
|
|
CREATE TABLE files
|
|
|
|
(
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
post_id INTEGER NOT NULL,
|
|
|
|
name VARCHAR NOT NULL,
|
|
|
|
ext VARCHAR NOT NULL,
|
|
|
|
size INTEGER NOT NULL,
|
2021-08-30 10:03:14 +03:00
|
|
|
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
2021-08-26 17:50:27 +03:00
|
|
|
FOREIGN KEY (post_id) REFERENCES posts (id)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DOWN
|
|
|
|
DROP TABLE files;
|
2021-08-31 19:27:23 +03:00
|
|
|
DROP TABLE posts;
|