Move 'anonymousCount' which was computed to a method in Hall. Seems more accurate
[vchess.git] / server / db / create.sql
CommitLineData
c326e657 1-- Database should be in this folder, and named 'vchess.sqlite'
86c9843c 2
da06a6eb 3create table Variants (
bf20f404
BA
4 id integer primary key,
5 name varchar unique,
6 description text
da06a6eb 7);
da06a6eb 8
8d7e2786 9create table Users (
bf20f404
BA
10 id integer primary key,
11 name varchar unique,
12 email varchar unique,
13 loginToken varchar,
14 loginTime datetime,
15 sessionToken varchar,
83494c7f 16 created datetime,
d9a7a1e4
BA
17 notify boolean,
18 newsRead datetime
8d7e2786
BA
19);
20
89021f18
BA
21create table Problems (
22 id integer primary key,
23 added datetime,
604b951e 24 fen varchar,
89021f18
BA
25 uid integer,
26 vid integer,
27 instruction text,
28 solution text,
29 foreign key (uid) references Users(id),
30 foreign key (vid) references Variants(id)
31);
8d7e2786 32
604b951e
BA
33create table News (
34 id integer primary key,
35 uid integer,
36 added datetime,
37 content text,
38 foreign key (uid) references Users(id)
39);
40
8d7e2786 41create table Challenges (
bf20f404
BA
42 id integer primary key,
43 added datetime,
44 uid integer,
45 target integer,
46 vid integer,
7ba4a5bc 47 randomness integer,
bf20f404 48 fen varchar,
71468011 49 cadence varchar,
bf20f404
BA
50 foreign key (uid) references Users(id),
51 foreign key (vid) references Variants(id)
8d7e2786
BA
52);
53
54create table Games (
bf20f404
BA
55 id integer primary key,
56 vid integer,
57 fenStart varchar, --initial state
58 fen varchar, --current state
0234201f
BA
59 white integer,
60 black integer,
aae89b49 61 score varchar default '*',
dcd68c41 62 scoreMsg varchar,
71468011 63 cadence varchar,
afde7666 64 randomness integer, --for rematch
71468011 65 created datetime,
aae89b49
BA
66 drawOffer character default '',
67 rematchOffer character default '',
68 deletedByWhite boolean,
69 deletedByBlack boolean,
0234201f
BA
70 foreign key (vid) references Variants(id),
71 foreign key (white) references Users(id),
72 foreign key (black) references Users(id)
8d7e2786
BA
73);
74
63ca2b89
BA
75create table Chats (
76 gid integer,
c547fbfb
BA
77 name varchar,
78 msg varchar,
3837d4f7 79 added datetime
63ca2b89
BA
80);
81
8d7e2786 82create table Moves (
bf20f404 83 gid integer,
f41ce580 84 squares varchar, --description, appear/vanish/from/to
bf20f404
BA
85 played datetime, --when was this move played?
86 idx integer, --index of the move in the game
bf20f404 87 foreign key (gid) references Games(id)
da06a6eb 88);
c326e657 89
0234201f
BA
90create index scoreIdx on Games(score);
91
8d7e2786 92pragma foreign_keys = on;