summaryrefslogtreecommitdiff
path: root/database/001_games.sql
diff options
context:
space:
mode:
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);