Marked as helpful by the asker
The model is fine. The RLS is not: lessons only checks owner_id, so a colleague you shared with cannot read them. You need a policy that joins through shares:
create policy "shared read" on lessons for select using (
exists (select 1 from shares s where s.course_id = lessons.course_id and s.user_id = auth.uid()));And index shares (user_id, course_id) or that policy gets slow.