yans/internal/backend/sqlite/migrations/001_init_schema.sql

27 lines
733 B
MySQL
Raw Normal View History

2022-01-17 22:38:56 +00:00
-- +goose Up
CREATE TABLE IF NOT EXISTS groups(
id INTEGER PRIMARY KEY AUTOINCREMENT,
group_name TEXT UNIQUE NOT NULL,
description TEXT,
2022-02-03 16:44:08 +00:00
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
2022-01-17 22:38:56 +00:00
);
CREATE TABLE IF NOT EXISTS articles(
id INTEGER PRIMARY KEY AUTOINCREMENT,
2022-02-03 16:44:08 +00:00
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
header TEXT,
2022-01-17 22:38:56 +00:00
thread TEXT,
body TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS articles_to_groups(
article_id INTEGER NOT NULL,
2022-01-17 22:38:56 +00:00
group_id INTEGER NOT NULL,
FOREIGN KEY (article_id) REFERENCES articles(id) ON DELETE CASCADE,
FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE
);
-- +goose Down
DROP TABLE groups;
DROP TABLE articles;
DROP TABLE articles_to_groups;