fix: enable lesson cascade delete (#335)
This commit is contained in:
@@ -376,25 +376,6 @@ ALTER TABLE "public"."lesson_completion" ALTER COLUMN "id" ADD GENERATED BY DEFA
|
||||
CACHE 1
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "public"."lesson_progress" (
|
||||
"id" bigint NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT "now"() NOT NULL,
|
||||
"lesson_id" "uuid",
|
||||
"student_id" "uuid",
|
||||
"is_complete" boolean DEFAULT false
|
||||
);
|
||||
|
||||
ALTER TABLE "public"."lesson_progress" OWNER TO "postgres";
|
||||
|
||||
ALTER TABLE "public"."lesson_progress" ALTER COLUMN "id" ADD GENERATED BY DEFAULT AS IDENTITY (
|
||||
SEQUENCE NAME "public"."lesson_progress_id_seq"
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "public"."option" (
|
||||
"id" bigint NOT NULL,
|
||||
"label" character varying NOT NULL,
|
||||
@@ -744,9 +725,6 @@ ALTER TABLE ONLY "public"."lesson_completion"
|
||||
ALTER TABLE ONLY "public"."lesson"
|
||||
ADD CONSTRAINT "lesson_pkey" PRIMARY KEY ("id");
|
||||
|
||||
ALTER TABLE ONLY "public"."lesson_progress"
|
||||
ADD CONSTRAINT "lesson_progress_pkey" PRIMARY KEY ("id");
|
||||
|
||||
ALTER TABLE ONLY "public"."option"
|
||||
ADD CONSTRAINT "option_pkey" PRIMARY KEY ("id");
|
||||
|
||||
@@ -900,12 +878,6 @@ ALTER TABLE ONLY "public"."lesson_completion"
|
||||
ALTER TABLE ONLY "public"."lesson"
|
||||
ADD CONSTRAINT "lesson_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "public"."course"("id");
|
||||
|
||||
ALTER TABLE ONLY "public"."lesson_progress"
|
||||
ADD CONSTRAINT "lesson_progress_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "public"."lesson"("id");
|
||||
|
||||
ALTER TABLE ONLY "public"."lesson_progress"
|
||||
ADD CONSTRAINT "lesson_progress_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "public"."groupmember"("id");
|
||||
|
||||
ALTER TABLE ONLY "public"."lesson"
|
||||
ADD CONSTRAINT "lesson_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "public"."profile"("id");
|
||||
|
||||
@@ -1111,14 +1083,6 @@ GRANT ALL ON SEQUENCE "public"."lesson_completion_id_seq" TO "anon";
|
||||
GRANT ALL ON SEQUENCE "public"."lesson_completion_id_seq" TO "authenticated";
|
||||
GRANT ALL ON SEQUENCE "public"."lesson_completion_id_seq" TO "service_role";
|
||||
|
||||
GRANT ALL ON TABLE "public"."lesson_progress" TO "anon";
|
||||
GRANT ALL ON TABLE "public"."lesson_progress" TO "authenticated";
|
||||
GRANT ALL ON TABLE "public"."lesson_progress" TO "service_role";
|
||||
|
||||
GRANT ALL ON SEQUENCE "public"."lesson_progress_id_seq" TO "anon";
|
||||
GRANT ALL ON SEQUENCE "public"."lesson_progress_id_seq" TO "authenticated";
|
||||
GRANT ALL ON SEQUENCE "public"."lesson_progress_id_seq" TO "service_role";
|
||||
|
||||
GRANT ALL ON TABLE "public"."option" TO "anon";
|
||||
GRANT ALL ON TABLE "public"."option" TO "authenticated";
|
||||
GRANT ALL ON TABLE "public"."option" TO "service_role";
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
-- Drop table cause it was never used
|
||||
drop table if exists public.lesson_progress;
|
||||
|
||||
alter table public.exercise
|
||||
drop constraint exercise_lesson_id_fkey,
|
||||
add constraint exercise_lesson_id_fkey foreign key (lesson_id) references lesson (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.lesson_comment
|
||||
drop constraint lesson_comment_lesson_id_fkey,
|
||||
add constraint lesson_comment_lesson_id_fkey foreign key (lesson_id) references lesson (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.question
|
||||
drop constraint question_exercise_id_fkey,
|
||||
add constraint question_exercise_id_fkey foreign key (exercise_id) references exercise (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.option
|
||||
drop constraint option_question_id_fkey,
|
||||
add constraint option_question_id_fkey foreign key (question_id) references question (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.question_answer
|
||||
drop constraint question_answer_question_id_fkey,
|
||||
add constraint question_answer_question_id_fkey foreign key (question_id) references question (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.submission
|
||||
drop constraint submission_exercise_id_fkey,
|
||||
add constraint submission_exercise_id_fkey foreign key (exercise_id) references exercise (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.submission
|
||||
drop constraint submission_course_id_fkey,
|
||||
add constraint submission_course_id_fkey foreign key (course_id) references course (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table public.question_answer
|
||||
drop constraint question_answer_submission_id_fkey,
|
||||
add constraint question_answer_submission_id_fkey foreign key (submission_id) references submission (id)
|
||||
on delete cascade;
|
||||
@@ -329,12 +329,6 @@ INSERT INTO "public"."lesson_comment" ("id", "created_at", "updated_at", "lesson
|
||||
--
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: lesson_progress; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
|
||||
|
||||
|
||||
INSERT INTO "public"."question" ("id", "question_type_id", "title", "created_at", "updated_at", "exercise_id", "name", "points", "order") VALUES
|
||||
(1, 2, 'What does MVC stand for', '2023-12-16 14:51:49.433261+00', '2023-12-16 14:51:49.433261+00', 'e2ea9fb8-6448-4f6c-a1d5-02c2b12cf862', 'd7316838-284f-4096-bf55-e51db9a98d47', 0, 0),
|
||||
|
||||
Reference in New Issue
Block a user