summaryrefslogtreecommitdiff
path: root/database/001_games.sql
diff options
context:
space:
mode:
authorJulien Dessaux2022-11-21 21:39:17 +0100
committerJulien Dessaux2022-11-21 21:39:17 +0100
commit8ac636186cf5f704264e7473864c54b3edaf4049 (patch)
tree6f575d5b4dc5afc0c087e0467c4dd7d6e4a6dd6b /database/001_games.sql
parentcleaned up the distinction between routes and controllers (diff)
downloadjeux-de-mots-8ac636186cf5f704264e7473864c54b3edaf4049.tar.gz
jeux-de-mots-8ac636186cf5f704264e7473864c54b3edaf4049.tar.bz2
jeux-de-mots-8ac636186cf5f704264e7473864c54b3edaf4049.zip
Added basic games handling
Diffstat (limited to 'database/001_games.sql')
-rw-r--r--database/001_games.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/database/001_games.sql b/database/001_games.sql
new file mode 100644
index 0000000..be45084
--- /dev/null
+++ b/database/001_games.sql
@@ -0,0 +1,12 @@
+CREATE TABLE games (
+ id INTEGER PRIMARY KEY,
+ player1 INTEGER NOT NULL,
+ player2 INTEGER NOT NULL,
+ data TEXT NOT NULL,
+ created_at DATE DEFAULT (datetime('now')),
+ last_move_at DATE DEFAULT NULL,
+ FOREIGN KEY (player1) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY (player2) REFERENCES users(id) ON DELETE CASCADE
+);
+CREATE INDEX idx_games_player1 ON games(player1);
+CREATE INDEX idx_games_player2 ON games(player2);