aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-28 15:58:34 +0900
committernsfisis <nsfisis@gmail.com>2024-07-28 15:59:12 +0900
commitd85cf0be57dd4394c588c340fbfa8483d981da02 (patch)
tree95b061b422bbe4c8199cb54f8b5ef6735a201b0a
parent05c44c895625d9dc4813ecbe53edefc3d8bd9b6d (diff)
downloadiosdc-japan-2024-albatross-d85cf0be57dd4394c588c340fbfa8483d981da02.tar.gz
iosdc-japan-2024-albatross-d85cf0be57dd4394c588c340fbfa8483d981da02.tar.zst
iosdc-japan-2024-albatross-d85cf0be57dd4394c588c340fbfa8483d981da02.zip
feat(backend): add game_players table
-rw-r--r--backend/db/models.go5
-rw-r--r--backend/schema.sql8
2 files changed, 13 insertions, 0 deletions
diff --git a/backend/db/models.go b/backend/db/models.go
index e60cb8a..cc08817 100644
--- a/backend/db/models.go
+++ b/backend/db/models.go
@@ -18,6 +18,11 @@ type Game struct {
ProblemID pgtype.Int4
}
+type GamePlayer struct {
+ GameID int32
+ UserID int32
+}
+
type Problem struct {
ProblemID int32
Title string
diff --git a/backend/schema.sql b/backend/schema.sql
index 1cd0700..f0b5b37 100644
--- a/backend/schema.sql
+++ b/backend/schema.sql
@@ -26,6 +26,14 @@ CREATE TABLE games (
CONSTRAINT fk_problem_id FOREIGN KEY(problem_id) REFERENCES problems(problem_id)
);
+CREATE TABLE game_players (
+ game_id INT NOT NULL,
+ user_id INT NOT NULL,
+ PRIMARY KEY (game_id, user_id),
+ CONSTRAINT fk_game_id FOREIGN KEY(game_id) REFERENCES games(game_id),
+ CONSTRAINT fk_user_id FOREIGN KEY(user_id) REFERENCES users(user_id)
+);
+
CREATE TABLE problems (
problem_id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,