TODO: finish draw offer logic + fix inCheck bug (no highlight)
[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
8d7e2786 20-- All the following tables are for correspondance play only
bebcc8d4 21-- (Live games are stored in browser)
8d7e2786
BA
22
23create table Challenges (
bf20f404
BA
24 id integer primary key,
25 added datetime,
26 uid integer,
27 target integer,
28 vid integer,
29 fen varchar,
30 timeControl varchar,
31 foreign key (uid) references Users(id),
32 foreign key (vid) references Variants(id)
8d7e2786
BA
33);
34
35create table Games (
bf20f404
BA
36 id integer primary key,
37 vid integer,
38 fenStart varchar, --initial state
39 fen varchar, --current state
40 score varchar,
dcd68c41 41 scoreMsg varchar,
bebcc8d4 42 timeControl varchar,
d431028c 43 created datetime, --used only for DB cleaning
dfeb96ea 44 drawOffer character,
bf20f404 45 foreign key (vid) references Variants(id)
8d7e2786
BA
46);
47
63ca2b89
BA
48create table Chats (
49 gid integer,
c547fbfb
BA
50 name varchar,
51 msg varchar,
3837d4f7 52 added datetime
63ca2b89
BA
53);
54
8d7e2786
BA
55-- Store informations about players in a corr game
56create table Players (
bf20f404
BA
57 gid integer,
58 uid integer,
59 color character,
bf20f404
BA
60 foreign key (gid) references Games(id),
61 foreign key (uid) references Users(id)
8d7e2786
BA
62);
63
64create table Moves (
bf20f404 65 gid integer,
f41ce580 66 squares varchar, --description, appear/vanish/from/to
bf20f404
BA
67 played datetime, --when was this move played?
68 idx integer, --index of the move in the game
bf20f404 69 foreign key (gid) references Games(id)
da06a6eb 70);
c326e657 71
8d7e2786 72pragma foreign_keys = on;