aboutsummaryrefslogtreecommitdiffstats
path: root/schema.sql
blob: 18ee95cef1f7ade73f43af6b74b85d50a7c8c999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
drop table if exists users;
create table users (
    id integer primary key autoincrement,
    user_name string not null,
    password string not null
);

drop table if exists news;
create table news (
    id integer primary key autoincrement,
    title string not null,
    date string default (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
    content string not null,
    content_cache string not null,
    user_id integer,
    FOREIGN KEY(user_id) REFERENCES users(id)
);

drop table if exists comments;
create table comments (
    id integer primary key autoincrement,
    date string default (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
    content string not null,
    content_cache string not null,
    user_id integer,
    news_id integer,
    FOREIGN KEY(user_id) REFERENCES users(id),
    FOREIGN KEY(news_id) REFERENCES news(id)
);