From 8ac636186cf5f704264e7473864c54b3edaf4049 Mon Sep 17 00:00:00 2001
From: Julien Dessaux
Date: Mon, 21 Nov 2022 21:39:17 +0100
Subject: Added basic games handling

---
 database/001_games.sql | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 database/001_games.sql

(limited to 'database/001_games.sql')

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);
-- 
cgit v1.2.3

