favorites
user_id
Supabase Auth user id. Each row belongs to one authenticated account.
Module 9.2
This Demo Lab page documents the cloud storage boundary for future favorites. EventMap does not read or write cloud favorites yet.
SQL migration
Copy the project SQL file into Supabase Studio SQL Editor and run it against the course project database.
supabase/sql/001_favorites_rls.sqlfavorites
Supabase Auth user id. Each row belongs to one authenticated account.
favorites
EventMap event id. Together with user_id it forms the primary key.
favorites
A JSON snapshot of EventCardData for future cloud favorites UI.
favorites
Server timestamps for storage metadata.
RLS policy
Authenticated users can read only rows where auth.uid() equals user_id.
RLS policy
with check prevents a browser request from creating a row for another user.
RLS policy
A user can remove only their own favorite rows.
RLS checklist
public.favorites stores user_id, event_id and event_snapshot for each saved event.
Row Level Security is enabled before browser-facing access is allowed.
The authenticated role receives select, insert and delete grants for public.favorites.
The SELECT policy compares auth.uid() with user_id.
The INSERT policy uses with check so a user can only create rows for their own user_id.
The DELETE policy compares auth.uid() with user_id before removing a favorite.
The browser client uses a publishable key, while row access stays protected by grants and policies.
Publishable key + RLS
A publishable key is expected in the browser client. It is safe only when the table grants are narrow and RLS policies scope every row to the current auth.uid(). Secret or service-role keys never belong in a Next.js frontend.