feat: lesson sections - v1 (#431)

* add todo

* update sidebar with sections

* add course versioning

* fix db reset issue

* v1 of working sections feature

* remove
This commit is contained in:
Rotimi Best
2024-08-14 10:27:37 +01:00
committed by GitHub
parent e7e2bc632b
commit ad421acf8d
30 changed files with 979 additions and 393 deletions
@@ -0,0 +1,127 @@
create type "public"."COURSE_VERSION" as enum ('V1', 'V2');
alter table "public"."lesson_language_history" drop constraint "lesson_language_history_lesson_language_id_fkey";
alter table "public"."lesson_language" drop constraint "public_lesson_language_lesson_id_fkey";
create table "public"."lesson_section" (
"id" uuid not null default gen_random_uuid(),
"created_at" timestamp with time zone not null default now(),
"updated_at" timestamp with time zone default now(),
"title" character varying,
"order" bigint default '0'::bigint,
"course_id" uuid
);
alter table "public"."lesson_section" enable row level security;
alter table "public"."course" add column "version" "COURSE_VERSION" not null default 'V1'::"COURSE_VERSION";
alter table "public"."lesson" add column "section_id" uuid;
CREATE UNIQUE INDEX lesson_section_pkey ON public.lesson_section USING btree (id);
alter table "public"."lesson_section" add constraint "lesson_section_pkey" PRIMARY KEY using index "lesson_section_pkey";
alter table "public"."lesson" add constraint "public_lesson_section_id_fkey" FOREIGN KEY (section_id) REFERENCES lesson_section(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."lesson" validate constraint "public_lesson_section_id_fkey";
alter table "public"."lesson_language_history" add constraint "public_lesson_language_history_lesson_language_id_fkey" FOREIGN KEY (lesson_language_id) REFERENCES lesson_language(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."lesson_language_history" validate constraint "public_lesson_language_history_lesson_language_id_fkey";
alter table "public"."lesson_section" add constraint "public_lesson_section_course_id_fkey" FOREIGN KEY (course_id) REFERENCES course(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."lesson_section" validate constraint "public_lesson_section_course_id_fkey";
alter table "public"."lesson_language" add constraint "public_lesson_language_lesson_id_fkey" FOREIGN KEY (lesson_id) REFERENCES lesson(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."lesson_language" validate constraint "public_lesson_language_lesson_id_fkey";
grant delete on table "public"."lesson_section" to "anon";
grant insert on table "public"."lesson_section" to "anon";
grant references on table "public"."lesson_section" to "anon";
grant select on table "public"."lesson_section" to "anon";
grant trigger on table "public"."lesson_section" to "anon";
grant truncate on table "public"."lesson_section" to "anon";
grant update on table "public"."lesson_section" to "anon";
grant delete on table "public"."lesson_section" to "authenticated";
grant insert on table "public"."lesson_section" to "authenticated";
grant references on table "public"."lesson_section" to "authenticated";
grant select on table "public"."lesson_section" to "authenticated";
grant trigger on table "public"."lesson_section" to "authenticated";
grant truncate on table "public"."lesson_section" to "authenticated";
grant update on table "public"."lesson_section" to "authenticated";
grant delete on table "public"."lesson_section" to "service_role";
grant insert on table "public"."lesson_section" to "service_role";
grant references on table "public"."lesson_section" to "service_role";
grant select on table "public"."lesson_section" to "service_role";
grant trigger on table "public"."lesson_section" to "service_role";
grant truncate on table "public"."lesson_section" to "service_role";
grant update on table "public"."lesson_section" to "service_role";
create policy "Enable read access for all users"
on "public"."lesson_section"
as permissive
for select
to public
using (true);
create policy "User must be an org member to DELETE"
on "public"."lesson_section"
as permissive
for delete
to public
using (is_user_in_group_with_role(( SELECT course.group_id
FROM course
WHERE (course.id = lesson_section.course_id)
LIMIT 1)));
create policy "User must be an org member to INSERT"
on "public"."lesson_section"
as permissive
for insert
to public
with check (is_user_in_group_with_role(( SELECT course.group_id
FROM course
WHERE (course.id = lesson_section.course_id)
LIMIT 1)));
create policy "User must be an org member to UPDATE"
on "public"."lesson_section"
as permissive
for update
to public
using (is_user_in_group_with_role(( SELECT course.group_id
FROM course
WHERE (course.id = lesson_section.course_id)
LIMIT 1)))
with check (is_user_in_group_with_role(( SELECT course.group_id
FROM course
WHERE (course.id = lesson_section.course_id)
LIMIT 1)));
+1 -1
View File
@@ -19,7 +19,7 @@ INSERT INTO "auth"."users" ("instance_id", "id", "aud", "role", "email", "encryp
-- Data for Name: identities; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--
INSERT INTO "auth"."identities" ("id", "user_id", "identity_data", "provider", "last_sign_in_at", "created_at", "updated_at") VALUES
INSERT INTO "auth"."identities" ("provider_id", "user_id", "identity_data", "provider", "last_sign_in_at", "created_at", "updated_at") VALUES
('01676a50-bb56-4c5e-8a61-fb9e9190fb10', '01676a50-bb56-4c5e-8a61-fb9e9190fb10', '{"sub": "01676a50-bb56-4c5e-8a61-fb9e9190fb10", "email": "test@test.com"}', 'email', '2023-11-22 10:09:32.225444+00', '2023-11-22 10:09:32.225521+00', '2023-11-22 10:09:32.225521+00'),
('7ac00503-8519-43c8-a5ea-b79aeca900b1', '7ac00503-8519-43c8-a5ea-b79aeca900b1', '{"sub": "7ac00503-8519-43c8-a5ea-b79aeca900b1", "email": "admin@test.com"}', 'email', '2023-12-16 14:04:38.302264+00', '2023-12-16 14:04:38.302326+00', '2023-12-16 14:04:38.302326+00'),
('0c256e75-aa40-4f62-8d30-0217ca1c60d9', '0c256e75-aa40-4f62-8d30-0217ca1c60d9', '{"sub": "0c256e75-aa40-4f62-8d30-0217ca1c60d9", "email": "student@test.com"}', 'email', '2023-12-18 17:08:57.410285+00', '2023-12-18 17:08:57.410344+00', '2023-12-18 17:08:57.410344+00');