micrach/migrations/1-init.sql

39 lines
654 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,
parent_id INT REFERENCES posts (id),
is_deleted BOOLEAN 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)
);
-- DOWN
DROP TABLE files;
DROP TABLE posts;