Skip to content
Snippets Groups Projects
Verified Commit 1b166dbe authored by Bayu Samudra's avatar Bayu Samudra
Browse files

fix: updating material and quiz schema

parent 6041ee9c
No related merge requests found
Pipeline #55027 failed with stages
-- +migrate Up
ALTER TABLE material
ADD COLUMN week INT;
-- +migrate Down
ALTER TABLE material
DROP COLUMN week;
\ No newline at end of file
-- +migrate Up
DROP TABLE quiz_take_choice_answer;
DROP TABLE quiz_choice_option;
DROP TABLE quiz_problem;
ALTER TABLE quiz
ADD COLUMN quiz_path TEXT;
-- +migrate Down
ALTER TABLE quiz
DROP COLUMN quiz_path;
CREATE TABLE public."quiz_problem" (
id UUID DEFAULT uuid_generate_v4(),
statement TEXT NOT NULL,
"type" PROBLEM_TYPE NOT NULL,
quiz_id UUID NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY(quiz_id)
REFERENCES public."quiz"(id)
);
CREATE TABLE public."quiz_choice_option" (
id UUID DEFAULT uuid_generate_v4(),
quiz_problem_id UUID NOT NULL,
statement TEXT NOT NULL,
is_answer BOOLEAN DEFAULT false,
PRIMARY KEY(id, quiz_problem_id),
FOREIGN KEY (quiz_problem_id)
REFERENCES public."quiz_problem"(id)
ON DELETE CASCADE
);
CREATE TABLE public."quiz_take_choice_answer" (
quiz_take_id UUID NOT NULL,
answer_choice_id UUID NOT NULL,
quiz_problem_id UUID NOT NULL,
PRIMARY KEY (quiz_take_id, quiz_problem_id),
FOREIGN KEY (quiz_take_id)
REFERENCES public."quiz_take"(id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (answer_choice_id, quiz_problem_id)
REFERENCES public."quiz_choice_option"(id, quiz_problem_id)
);
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment