modified schema to support chat rooms
[chaz/chatty] / db / schema.sql
1
2 PRAGMA foreign_keys = ON;
3
4 CREATE TABLE room (
5 id INTEGER PRIMARY KEY,
6 name TEXT,
7 created TIMESTAMP DEFAULT NOW
8 );
9
10 CREATE TABLE account (
11 id INTEGER PRIMARY KEY,
12 email TEXT,
13 username TEXT UNIQUE,
14 password TEXT NOT NULL,
15 status TEXT DEFAULT 'active',
16 current_room INTEGER REFERENCES room(id)
17 );
18
19 CREATE TABLE message (
20 id INTEGER PRIMARY KEY,
21 posted TIMESTAMP DEFAULT NOW,
22 author INTEGER REFERENCES account(id),
23 room INTEGER REFERENCES room(id),
24 content TEXT
25 );
26
27 INSERT INTO account (username, password) VALUES ('chaz', 'mypass');
28 INSERT INTO account (username, password) VALUES ('jdoe', 'foobar');
29
This page took 0.027945 seconds and 4 git commands to generate.