generated from CodeChefVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,206 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ations/20240923132455_cookoff_backend.sql → database/migrations/20240926184603.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
-- Create "questions" table | ||
CREATE TABLE "public"."questions" ("id" uuid NOT NULL, "description" text NULL, "title" text NULL, "input_format" text NULL, "points" integer NULL, "round" integer NOT NULL, "constraints" text NULL, "output_format" text NULL, PRIMARY KEY ("id")); | ||
CREATE TABLE "public"."questions" ("id" uuid NOT NULL, "description" text NOT NULL, "title" text NOT NULL, "input_format" text[] NULL, "points" integer NOT NULL, "round" integer NOT NULL, "constraints" text[] NOT NULL, "output_format" text[] NOT NULL, "sample_test_input" text[] NULL, "sample_test_output" text[] NULL, "explanation" text[] NULL, PRIMARY KEY ("id")); | ||
-- Create "testcases" table | ||
CREATE TABLE "public"."testcases" ("id" uuid NOT NULL, "expected_output" text NULL, "memory" text NULL, "input" text NULL, "hidden" boolean NULL, "runtime" numeric NULL, "question_id" uuid NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "testcases_question_id_fkey" FOREIGN KEY ("question_id") REFERENCES "public"."questions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); | ||
CREATE TABLE "public"."testcases" ("id" uuid NOT NULL, "expected_output" text NOT NULL, "memory" numeric NOT NULL, "input" text NOT NULL, "hidden" boolean NOT NULL, "runtime" numeric NOT NULL, "question_id" uuid NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "testcases_question_id_fkey" FOREIGN KEY ("question_id") REFERENCES "public"."questions" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); | ||
-- Create "users" table | ||
CREATE TABLE "public"."users" ("id" uuid NOT NULL, "email" text NOT NULL, "reg_no" text NOT NULL, "password" text NOT NULL, "role" text NOT NULL, "round_qualified" integer NOT NULL DEFAULT 0, "score" integer NULL DEFAULT 0, "name" text NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "users_email_key" UNIQUE ("email"), CONSTRAINT "users_reg_no_key" UNIQUE ("reg_no")); | ||
-- Create "submissions" table | ||
CREATE TABLE "public"."submissions" ("id" uuid NOT NULL, "question_id" uuid NOT NULL, "testcases_passed" integer NULL DEFAULT 0, "testcases_failed" integer NULL DEFAULT 0, "runtime" numeric NULL, "submission_time" timestamp NULL DEFAULT CURRENT_TIMESTAMP, "testcase_id" uuid NULL, "language_id" integer NOT NULL, "description" text NULL, "memory" integer NULL, "user_id" uuid NULL, "status" text NULL, PRIMARY KEY ("id"), CONSTRAINT "submissions_question_id_fkey" FOREIGN KEY ("question_id") REFERENCES "public"."questions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "submissions_testcase_id_fkey" FOREIGN KEY ("testcase_id") REFERENCES "public"."testcases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "submissions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); | ||
CREATE TABLE "public"."submissions" ("id" uuid NOT NULL, "question_id" uuid NOT NULL, "testcases_passed" integer NULL DEFAULT 0, "testcases_failed" integer NULL DEFAULT 0, "runtime" numeric NULL, "submission_time" timestamp NULL DEFAULT CURRENT_TIMESTAMP, "testcase_id" uuid NULL, "language_id" integer NOT NULL, "description" text NULL, "memory" integer NULL, "user_id" uuid NULL, "status" text NULL, PRIMARY KEY ("id"), CONSTRAINT "submissions_question_id_fkey" FOREIGN KEY ("question_id") REFERENCES "public"."questions" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "submissions_testcase_id_fkey" FOREIGN KEY ("testcase_id") REFERENCES "public"."testcases" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "submissions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Modify "submissions" table | ||
ALTER TABLE "public"."submissions" DROP COLUMN "testcase_id", ALTER COLUMN "memory" TYPE numeric; | ||
-- Create "submission_results" table | ||
CREATE TABLE "public"."submission_results" ("id" uuid NOT NULL, "submission_id" uuid NOT NULL, "runtime" numeric NOT NULL, "memory" numeric NOT NULL, "description" text NULL, PRIMARY KEY ("id"), CONSTRAINT "submission_results_submission_id_fkey" FOREIGN KEY ("submission_id") REFERENCES "public"."submissions" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
h1:sfG3u9dWuQiUXQ0Fia9dOLA6w4mncdKU2PNaX0NqGCk= | ||
20240923132455_cookoff_backend.sql h1:31jiDjFKi7AywbVApUvBQeL5Fd8+cXxLzIUypIYB2dw= | ||
h1:SfrlwGx8g4V5VkQK9l6EfwFchAwCMGWIUQS/ZHvWXS8= | ||
20240926184603.sql h1:wPT86iP7DBa4YxmbZDqwieI8GAecgGAw2JyG9S82ngI= | ||
20240926192436.sql h1:b5lQ7n1SlrGlBZV7y+HeCOZKbjkj3A8Q79iP+s73t74= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- name: CreateSubmissionStatus :exec | ||
INSERT INTO submission_results (id, submission_id, testcase_id ,status ,runtime, memory, description) | ||
VALUES ($1, $2, $3, $4, $5, $6, $7); | ||
|
||
-- name: GetStatsForFinalSubEntry :many | ||
SELECT | ||
runtime, | ||
memory, | ||
status | ||
FROM submission_results | ||
WHERE submission_id = $1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.