Commit d7f3b88b authored by tianzhou's avatar tianzhou
Browse files

Create user, post, comment table for dev environment

parent c4233a36
CREATE TABLE `user` (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL,
email TEXT NOT NULL
);
CREATE TABLE post (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL,
content TEXT NOT NULL,
author_id INTEGER NOT NULL,
FOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT
);
CREATE TABLE comment (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
content TEXT NOT NULL,
post_id INTEGER NOT NULL,
author_id INTEGER NOT NULL,
FOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,
FOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment