aboutsummaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-01-03 15:26:00 +0100
committerlonkaars <l.leblansch@gmail.com>2021-01-03 15:26:00 +0100
commitbcaccefc8bea56c99b21a63bcb6b29f358174bf1 (patch)
tree6146fde19d57711db785cdebf320aaff5945b8f6 /database
parenteb028f273531044dc92c011b9e69c123752d0372 (diff)
added database initialization
Diffstat (limited to 'database')
-rwxr-xr-xdatabase/init_db.sh1
-rw-r--r--database/init_db.sql43
2 files changed, 44 insertions, 0 deletions
diff --git a/database/init_db.sh b/database/init_db.sh
new file mode 100755
index 0000000..0c5515b
--- /dev/null
+++ b/database/init_db.sh
@@ -0,0 +1 @@
+sqlite3 database.db < init_db.sql
diff --git a/database/init_db.sql b/database/init_db.sql
new file mode 100644
index 0000000..cf26f7b
--- /dev/null
+++ b/database/init_db.sql
@@ -0,0 +1,43 @@
+PRAGMA foreign_keys = ON;
+
+create table users (
+ user_id text primary key not null,
+ username varchar(35) not null,
+ email text not null,
+ country text,
+ password_salt text not null,
+ password_hash text not null,
+ registered integer not null,
+ valid_tokens text,
+ verified_email boolean not null,
+ type text not null,
+ preferences text not null,
+ avatar text,
+ presence text
+);
+
+create table games (
+ game_id text primary key not null,
+ parent_game text,
+ moves text,
+ player_1_id text not null,
+ player_2_id text,
+ outcome text,
+ timestamp integer,
+ duration integer,
+ rating_delta_player_1 integer,
+ rating_delta_player_2 integer,
+ ranked boolean,
+ status text not null,
+ foreign key(player_1_id) references users(user_id),
+ foreign key(player_2_id) references users(user_id)
+);
+
+create table social (
+ user_id text not null,
+ friends text,
+ blocked text,
+ pending text,
+ foreign key(user_id) references users(user_id)
+);
+