fix: enable lesson cascade delete (#335)
This commit is contained in:
@@ -63,6 +63,8 @@ export async function handleDelete(lessonId: Lesson['id'] | undefined) {
|
||||
}
|
||||
|
||||
lessons.update((_lessons) => _lessons.filter((lesson) => lesson.id !== lessonId));
|
||||
|
||||
snackbar.success('snackbar.generic.success_delete');
|
||||
}
|
||||
|
||||
console.log(`lessonId`, lessonId);
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "Beim Absenden der Umfrage ist ein Fehler aufgetreten"
|
||||
}
|
||||
},
|
||||
"success_update": "Erfolgreich geupdated"
|
||||
"success_update": "Erfolgreich geupdated",
|
||||
"generic": {
|
||||
"success_delete": "Erfolgreich gelöscht",
|
||||
"try_again": "Fehler – Bitte versuchen Sie es später noch einmal"
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "Übungen",
|
||||
|
||||
@@ -1265,6 +1265,11 @@
|
||||
"setup": {
|
||||
"info_lesson": "You Need to Create a lesson",
|
||||
"info_course": "You need to create a course"
|
||||
},
|
||||
|
||||
"generic": {
|
||||
"success_delete": "Deleted successfully",
|
||||
"try_again": "Error - Please try again later"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "Se produjo un error al enviar la encuesta."
|
||||
}
|
||||
},
|
||||
"success_update": "Actualizado exitosamente"
|
||||
"success_update": "Actualizado exitosamente",
|
||||
"generic": {
|
||||
"success_delete": "Borrado exitosamente",
|
||||
"try_again": "Error: inténtelo de nuevo más tarde"
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "Ejercicios",
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "Une erreur s'est produite lors de la soumission du sondage"
|
||||
}
|
||||
},
|
||||
"success_update": "Mis à jour avec succés"
|
||||
"success_update": "Mis à jour avec succés",
|
||||
"generic": {
|
||||
"success_delete": "Supprimé avec succès",
|
||||
"try_again": "Erreur - Veuillez réessayer plus tard"
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "Des exercices",
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "मतदान सबमिट करते समय एक त्रुटि उत्पन्न हुई"
|
||||
}
|
||||
},
|
||||
"success_update": "सफलतापूर्वक अपडेट किया गया"
|
||||
"success_update": "सफलतापूर्वक अपडेट किया गया",
|
||||
"generic": {
|
||||
"success_delete": "सफलतापूर्वक मिटाया गया",
|
||||
"try_again": "त्रुटि - कृपया बाद में पुनः प्रयास करें"
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "अभ्यास",
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "Ocorreu um erro ao enviar a enquete"
|
||||
}
|
||||
},
|
||||
"success_update": "Atualizado com sucesso"
|
||||
"success_update": "Atualizado com sucesso",
|
||||
"generic": {
|
||||
"success_delete": "Apagado com sucesso",
|
||||
"try_again": "Erro - Tente novamente mais tarde"
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "Exercícios",
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "Произошла ошибка при отправке опроса"
|
||||
}
|
||||
},
|
||||
"success_update": "Успешно Обновлено"
|
||||
"success_update": "Успешно Обновлено",
|
||||
"generic": {
|
||||
"success_delete": "Удален успешно",
|
||||
"try_again": "Ошибка. Повторите попытку позже."
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "Упражнения",
|
||||
|
||||
@@ -154,7 +154,11 @@
|
||||
"submitting_poll": "Đã xảy ra lỗi khi gửi cuộc thăm dò ý kiến"
|
||||
}
|
||||
},
|
||||
"success_update": "Cập nhật thành công"
|
||||
"success_update": "Cập nhật thành công",
|
||||
"generic": {
|
||||
"success_delete": "Đã xoá thành công",
|
||||
"try_again": "Lỗi - Vui lòng thử lại sau"
|
||||
}
|
||||
},
|
||||
"exercises": {
|
||||
"heading": "Bài tập",
|
||||
|
||||
@@ -322,7 +322,10 @@
|
||||
<OverflowMenuItem
|
||||
danger
|
||||
text={$t('course.navItem.lessons.add_lesson.delete')}
|
||||
on:click={() => handleDelete(lesson.id)}
|
||||
on:click={() => {
|
||||
lessonToDelete = lesson;
|
||||
openDeleteModal = true;
|
||||
}}
|
||||
/>
|
||||
</OverflowMenu>
|
||||
</RoleBasedSecurity>
|
||||
|
||||
@@ -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