mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
39 lines
654 B
SQL
39 lines
654 B
SQL
-- UP
|
|
-- Posts
|
|
CREATE TABLE posts
|
|
(
|
|
id SERIAL NOT NULL,
|
|
|
|
is_parent BOOLEAN NOT NULL,
|
|
parent_id INT REFERENCES posts (id),
|
|
|
|
is_deleted BOOLEAN NOT NULL,
|
|
|
|
title VARCHAR NOT NULL,
|
|
text TEXT NOT NULL,
|
|
is_sage BOOLEAN NOT NULL,
|
|
|
|
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
|
updated_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
|
|
-- 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,
|
|
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
|
FOREIGN KEY (post_id) REFERENCES posts (id)
|
|
);
|
|
|
|
|
|
|
|
-- DOWN
|
|
DROP TABLE files;
|
|
DROP TABLE posts; |