surwiki/migrations/20170820204425_add_articles/up.sql
2017-08-20 23:44:52 +02:00

16 lines
367 B
SQL

CREATE TABLE articles (
id INTEGER PRIMARY KEY NOT NULL
);
CREATE TABLE article_revisions (
article_id INTEGER NOT NULL,
revision INTEGER NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
title TEXT NOT NULL,
body TEXT NOT NULL,
PRIMARY KEY (article_id, revision),
FOREIGN KEY (article_id) REFERENCES articles(id)
);