micrach/migrations/1-init.sql

37 lines
721 B
MySQL
Raw Normal View History

2021-08-26 17:50:27 +03:00
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
);
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)
);
CREATE TABLE migrations
(
id INT NOT NULL,
name VARCHAR NOT NULL,
created_at TIMESTAMP DEFAULT NOW() NOT NULL
)