micrach/migrations/000001_init.up.sql

34 lines
627 B
MySQL
Raw Normal View History

2021-08-26 17:50:27 +03:00
-- UP
-- Posts
CREATE TABLE posts
(
id SERIAL NOT NULL,
is_parent BOOLEAN NOT NULL,
2021-08-31 22:10:24 +03:00
parent_id INT REFERENCES posts (id) NULL,
2021-08-31 22:10:24 +03:00
is_deleted BOOLEAN DEFAULT false NOT NULL,
2021-08-26 17:50:27 +03:00
title VARCHAR NOT NULL,
text TEXT NOT NULL,
is_sage BOOLEAN NOT NULL,
2021-08-26 17:50:27 +03:00
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
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)
);