full-stack-school/supabase/migrations/20260307120000_teacher_school_insert_policy.sql
2026-03-07 17:32:08 +00:00

10 lines
298 B
SQL

-- Allow teachers to add themselves to a school (link from directory on My Schools page)
CREATE POLICY "Teachers can insert their own TeacherSchool mapping"
ON "TeacherSchool"
FOR INSERT
TO authenticated
WITH CHECK (
requesting_user_role() = 'teacher'
AND "teacherId" = requesting_user_id()
);