blog/backend/migrations/2023-02-06-134456_init/up.sql

22 lines
477 B
MySQL
Raw Normal View History

2023-02-07 06:02:51 +00:00
CREATE TABLE tags(
id SERIAL PRIMARY KEY,
name TEXT UNIQUE NOT NULL
);
CREATE TABLE posts(
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
slug TEXT UNIQUE NOT NULL,
description TEXT NOT NULL,
content TEXT NOT NULL,
published_at DATE NOT NULL,
edited_at DATE,
active BOOLEAN NOT NULL
2023-02-12 08:18:56 +00:00
);
CREATE TABLE post_tags(
id SERIAL PRIMARY KEY,
post_id INTEGER NOT NULL REFERENCES posts(id),
tag_id INTEGER NOT NULL REFERENCES tags(id)
);