From ecfd4d0a0ab195cdc28cf1f83a6e6885a585d945 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 17 Aug 2025 17:31:45 +0900
Subject: fix(backend): order of table definition

---
 backend/schema.sql | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'backend/schema.sql')

diff --git a/backend/schema.sql b/backend/schema.sql
index 6550fcd..6408cbc 100644
--- a/backend/schema.sql
+++ b/backend/schema.sql
@@ -46,6 +46,19 @@ CREATE TABLE game_main_players (
     CONSTRAINT fk_user_id FOREIGN KEY(user_id) REFERENCES users(user_id)
 );
 
+CREATE TABLE submissions (
+    submission_id SERIAL      PRIMARY KEY,
+    game_id       INT         NOT NULL,
+    user_id       INT         NOT NULL,
+    code          TEXT        NOT NULL,
+    code_size     INT         NOT NULL,
+    status        VARCHAR(16) NOT NULL,
+    created_at    TIMESTAMP   NOT NULL DEFAULT NOW(),
+    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 INDEX idx_submissions_game_id_user_id ON submissions(game_id, user_id);
+
 CREATE TABLE game_states (
     game_id INT NOT NULL,
     user_id INT NOT NULL,
@@ -67,19 +80,6 @@ CREATE TABLE testcases (
 );
 CREATE INDEX idx_testcases_problem_id ON testcases(problem_id);
 
-CREATE TABLE submissions (
-    submission_id SERIAL      PRIMARY KEY,
-    game_id       INT         NOT NULL,
-    user_id       INT         NOT NULL,
-    code          TEXT        NOT NULL,
-    code_size     INT         NOT NULL,
-    status        VARCHAR(16) NOT NULL,
-    created_at    TIMESTAMP   NOT NULL DEFAULT NOW(),
-    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 INDEX idx_submissions_game_id_user_id ON submissions(game_id, user_id);
-
 CREATE TABLE testcase_results (
     testcase_result_id SERIAL      PRIMARY KEY,
     submission_id      INT         NOT NULL,
-- 
cgit v1.3.1

