aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-28 13:03:17 +0900
committernsfisis <nsfisis@gmail.com>2024-07-28 13:03:17 +0900
commit1520f8c87a4ab9ff4bd2e8af6debf8f361e0582e (patch)
tree40babf2259e904b08346bd426b62a99e268cf801 /backend
parent90741e8336b4ffba090bf08c3b899992860e2d98 (diff)
downloadiosdc-japan-2024-albatross-1520f8c87a4ab9ff4bd2e8af6debf8f361e0582e.tar.gz
iosdc-japan-2024-albatross-1520f8c87a4ab9ff4bd2e8af6debf8f361e0582e.tar.zst
iosdc-japan-2024-albatross-1520f8c87a4ab9ff4bd2e8af6debf8f361e0582e.zip
feat(backend): change games table and create problems table
Diffstat (limited to 'backend')
-rw-r--r--backend/db/models.go17
-rw-r--r--backend/schema.sql18
2 files changed, 27 insertions, 8 deletions
diff --git a/backend/db/models.go b/backend/db/models.go
index a54fd8c..e60cb8a 100644
--- a/backend/db/models.go
+++ b/backend/db/models.go
@@ -9,10 +9,19 @@ import (
)
type Game struct {
- GameID int32
- Type string
- CreatedAt pgtype.Timestamp
- State string
+ GameID int32
+ State string
+ DisplayName string
+ DurationSeconds int32
+ CreatedAt pgtype.Timestamp
+ StartedAt pgtype.Timestamp
+ ProblemID pgtype.Int4
+}
+
+type Problem struct {
+ ProblemID int32
+ Title string
+ Description string
}
type User struct {
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
);