Commit | Line | Data |
---|---|---|
c326e657 | 1 | -- Database should be in this folder, and named 'vchess.sqlite' |
86c9843c | 2 | |
da06a6eb | 3 | create table Variants ( |
bf20f404 BA |
4 | id integer primary key, |
5 | name varchar unique, | |
6 | description text | |
da06a6eb | 7 | ); |
da06a6eb | 8 | |
8d7e2786 | 9 | create 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 | |
23 | create 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 | ||
92a523d1 | 35 | -- NOTE: no need for a "created" field, it's deduced from first move playing time |
8d7e2786 | 36 | create table Games ( |
bf20f404 BA |
37 | id integer primary key, |
38 | vid integer, | |
39 | fenStart varchar, --initial state | |
40 | fen varchar, --current state | |
41 | score varchar, | |
bebcc8d4 | 42 | timeControl varchar, |
d431028c | 43 | created datetime, --used only for DB cleaning |
b7cbbda1 | 44 | drawOffer boolean, |
bf20f404 | 45 | foreign key (vid) references Variants(id) |
8d7e2786 BA |
46 | ); |
47 | ||
63ca2b89 BA |
48 | create table Chats ( |
49 | gid integer, | |
50 | uid integer, | |
51 | ); | |
52 | ||
8d7e2786 BA |
53 | -- Store informations about players in a corr game |
54 | create table Players ( | |
bf20f404 BA |
55 | gid integer, |
56 | uid integer, | |
57 | color character, | |
bf20f404 BA |
58 | foreign key (gid) references Games(id), |
59 | foreign key (uid) references Users(id) | |
8d7e2786 BA |
60 | ); |
61 | ||
62 | create table Moves ( | |
bf20f404 | 63 | gid integer, |
f41ce580 | 64 | squares varchar, --description, appear/vanish/from/to |
bf20f404 BA |
65 | played datetime, --when was this move played? |
66 | idx integer, --index of the move in the game | |
bf20f404 | 67 | foreign key (gid) references Games(id) |
da06a6eb | 68 | ); |
c326e657 | 69 | |
8d7e2786 | 70 | pragma foreign_keys = on; |