Draft of a problems section + news system
[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,
bf20f404 17 notify boolean
8d7e2786
BA
18);
19
89021f18
BA
20create table Problems (
21 id integer primary key,
22 added datetime,
604b951e 23 fen varchar,
89021f18
BA
24 uid integer,
25 vid integer,
26 instruction text,
27 solution text,
28 foreign key (uid) references Users(id),
29 foreign key (vid) references Variants(id)
30);
8d7e2786 31
604b951e
BA
32create table News (
33 id integer primary key,
34 uid integer,
35 added datetime,
36 content text,
37 foreign key (uid) references Users(id)
38);
39
8d7e2786 40create table Challenges (
bf20f404
BA
41 id integer primary key,
42 added datetime,
43 uid integer,
44 target integer,
45 vid integer,
46 fen varchar,
71468011 47 cadence varchar,
bf20f404
BA
48 foreign key (uid) references Users(id),
49 foreign key (vid) references Variants(id)
8d7e2786
BA
50);
51
52create table Games (
bf20f404
BA
53 id integer primary key,
54 vid integer,
55 fenStart varchar, --initial state
56 fen varchar, --current state
57 score varchar,
dcd68c41 58 scoreMsg varchar,
71468011
BA
59 cadence varchar,
60 created datetime,
dfeb96ea 61 drawOffer character,
bf20f404 62 foreign key (vid) references Variants(id)
8d7e2786
BA
63);
64
63ca2b89
BA
65create table Chats (
66 gid integer,
c547fbfb
BA
67 name varchar,
68 msg varchar,
3837d4f7 69 added datetime
63ca2b89
BA
70);
71
8d7e2786
BA
72-- Store informations about players in a corr game
73create table Players (
bf20f404
BA
74 gid integer,
75 uid integer,
76 color character,
bf20f404
BA
77 foreign key (gid) references Games(id),
78 foreign key (uid) references Users(id)
8d7e2786
BA
79);
80
81create table Moves (
bf20f404 82 gid integer,
f41ce580 83 squares varchar, --description, appear/vanish/from/to
bf20f404
BA
84 played datetime, --when was this move played?
85 idx integer, --index of the move in the game
bf20f404 86 foreign key (gid) references Games(id)
da06a6eb 87);
c326e657 88
8d7e2786 89pragma foreign_keys = on;