summaryrefslogtreecommitdiff
path: root/database/001_games.sql
blob: be45084f2a6112bc67ebdcf174558d6f96055b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
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);