summaryrefslogtreecommitdiff
path: root/db/0-create.psql
blob: 732c986c871d5c279a05fd8cf4d5afe52937df76 (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
CREATE TABLE users (
    user_id integer PRIMARY KEY,
    nick text UNIQUE NOT NULL,
    email text NOT NULL,
    salt integer NOT NULL,
    password_hash text NOT NULL,
    created_on timestamp NOT NULL
);

CREATE TABLE rooms (
    room_id integer PRIMARY KEY,
    name text UNIQUE NOT NULL,
    created_on timestamp NOT NULL
);

CREATE TABLE messages (
    message_id integer PRIMARY KEY,
    user_id integer NOT NULL REFERENCES users,
    room_id integer NOT NULL REFERENCES rooms,
    content text NOT NULL,
    created_on timestamp NOT NULL
);

CREATE TABLE user_session (
    session_id integer PRIMARY KEY,
    user_id NOT NULL REFERENCES users,
    id_address text NOT NULL,
    ttl timestamp NOT NULL
);