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