Voyage/voyage.sql

29 lines
708 B
MySQL
Raw Normal View History

2019-12-06 18:13:43 -05:00
CREATE TABLE IF NOT EXISTS thread(
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
time TIMESTAMP WITH TIME ZONE NOT NULL
);
CREATE TABLE IF NOT EXISTS post(
thread_id INTEGER REFERENCES thread(id) ON DELETE CASCADE NOT NULL,
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
trip_code TEXT,
subject TEXT,
time TIMESTAMP WITH TIME ZONE NOT NULL,
file_url TEXT,
file_name TEXT,
file_md5 TEXT,
body TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS link(
link_from INTEGER REFERENCES post(id) ON DELETE CASCADE NOT NULL,
link_to INTEGER REFERENCES post(id) ON DELETE CASCADE NOT NULL
);
CREATE TABLE IF NOT EXISTS tag(
post_id INTEGER REFERENCES post(id) ON DELETE CASCADE NOT NULL,
name TEXT NOT NULL
);