tldraw implementation
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- CreateTable LessonWhiteboard
|
||||
CREATE TABLE "LessonWhiteboard" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"lessonId" INTEGER NOT NULL,
|
||||
"title" TEXT,
|
||||
"plannedSnapshotData" JSONB,
|
||||
"liveSnapshotData" JSONB,
|
||||
"finalSnapshotData" JSONB,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "LessonWhiteboard_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "LessonWhiteboard" ADD CONSTRAINT "LessonWhiteboard_lessonId_fkey" FOREIGN KEY ("lessonId") REFERENCES "Lesson"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "LessonWhiteboard_lessonId_key" ON "LessonWhiteboard"("lessonId");
|
||||
@@ -0,0 +1,15 @@
|
||||
ALTER TABLE "LessonWhiteboard" ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY "Admins have full access" ON "LessonWhiteboard" FOR ALL USING (is_admin());
|
||||
|
||||
CREATE POLICY "Users can view permitted lesson whiteboards" ON "LessonWhiteboard" FOR SELECT USING (
|
||||
is_admin() OR "lessonId" IN (SELECT auth_user_lessons())
|
||||
);
|
||||
|
||||
CREATE POLICY "Teachers can update lesson whiteboards" ON "LessonWhiteboard" FOR UPDATE USING (
|
||||
is_admin() OR ("lessonId" IN (SELECT auth_user_lessons()) AND requesting_user_role() = 'teacher')
|
||||
);
|
||||
|
||||
CREATE POLICY "Teachers can insert lesson whiteboards" ON "LessonWhiteboard" FOR INSERT WITH CHECK (
|
||||
is_admin() OR ("lessonId" IN (SELECT auth_user_lessons()) AND requesting_user_role() = 'teacher')
|
||||
);
|
||||
Reference in New Issue
Block a user