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, |
d9a7a1e4 BA |
17 | notify boolean, |
18 | newsRead datetime | |
8d7e2786 BA |
19 | ); |
20 | ||
89021f18 BA |
21 | create 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 |
33 | create 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 | 41 | create 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 | ||
54 | create table Games ( | |
bf20f404 BA |
55 | id integer primary key, |
56 | vid integer, | |
57 | fenStart varchar, --initial state | |
58 | fen varchar, --current state | |
aae89b49 | 59 | score varchar default '*', |
dcd68c41 | 60 | scoreMsg varchar, |
71468011 | 61 | cadence varchar, |
afde7666 | 62 | randomness integer, --for rematch |
71468011 | 63 | created datetime, |
aae89b49 BA |
64 | drawOffer character default '', |
65 | rematchOffer character default '', | |
66 | deletedByWhite boolean, | |
67 | deletedByBlack boolean, | |
bf20f404 | 68 | foreign key (vid) references Variants(id) |
8d7e2786 BA |
69 | ); |
70 | ||
63ca2b89 BA |
71 | create table Chats ( |
72 | gid integer, | |
c547fbfb BA |
73 | name varchar, |
74 | msg varchar, | |
3837d4f7 | 75 | added datetime |
63ca2b89 BA |
76 | ); |
77 | ||
8d7e2786 BA |
78 | -- Store informations about players in a corr game |
79 | create table Players ( | |
bf20f404 BA |
80 | gid integer, |
81 | uid integer, | |
82 | color character, | |
bf20f404 BA |
83 | foreign key (gid) references Games(id), |
84 | foreign key (uid) references Users(id) | |
8d7e2786 BA |
85 | ); |
86 | ||
87 | create table Moves ( | |
bf20f404 | 88 | gid integer, |
f41ce580 | 89 | squares varchar, --description, appear/vanish/from/to |
bf20f404 BA |
90 | played datetime, --when was this move played? |
91 | idx integer, --index of the move in the game | |
bf20f404 | 92 | foreign key (gid) references Games(id) |
da06a6eb | 93 | ); |
c326e657 | 94 | |
8d7e2786 | 95 | pragma foreign_keys = on; |