From 1520f8c87a4ab9ff4bd2e8af6debf8f361e0582e Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 28 Jul 2024 13:03:17 +0900
Subject: feat(backend): change games table and create problems table

---
 backend/schema.sql | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

(limited to 'backend/schema.sql')

diff --git a/backend/schema.sql b/backend/schema.sql
index 6696242..1cd0700 100644
--- a/backend/schema.sql
+++ b/backend/schema.sql
@@ -16,8 +16,18 @@ CREATE TABLE user_auths (
 );
 
 CREATE TABLE games (
-    game_id    SERIAL       PRIMARY KEY,
-    type       VARCHAR(255) NOT NULL,
-    created_at TIMESTAMP    NOT NULL DEFAULT NOW(),
-    state      VARCHAR(255) NOT NULL
+    game_id          SERIAL       PRIMARY KEY,
+    state            VARCHAR(32)  NOT NULL,
+    display_name     VARCHAR(255) NOT NULL,
+    duration_seconds INT          NOT NULL,
+    created_at       TIMESTAMP    NOT NULL DEFAULT NOW(),
+    started_at       TIMESTAMP,
+    problem_id       INT,
+    CONSTRAINT fk_problem_id FOREIGN KEY(problem_id) REFERENCES problems(problem_id)
+);
+
+CREATE TABLE problems (
+    problem_id  SERIAL       PRIMARY KEY,
+    title       VARCHAR(255) NOT NULL,
+    description TEXT         NOT NULL
 );
-- 
cgit v1.2.3-70-g09d2

