-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-schema.sql
More file actions
29 lines (23 loc) · 1002 Bytes
/
Copy pathsupabase-schema.sql
File metadata and controls
29 lines (23 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- Run this in Supabase SQL Editor (https://supabase.com/dashboard -> SQL Editor)
-- 1. Create bookmarks table
create table public.bookmarks (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users(id) on delete cascade not null default auth.uid(),
url text not null,
title text not null,
created_at timestamptz default now() not null
);
-- 2. Enable Row Level Security
alter table public.bookmarks enable row level security;
-- 3. RLS policies: users can only see/manage their own bookmarks
create policy "Users can view their own bookmarks"
on public.bookmarks for select
using (auth.uid() = user_id);
create policy "Users can insert their own bookmarks"
on public.bookmarks for insert
with check (auth.uid() = user_id);
create policy "Users can delete their own bookmarks"
on public.bookmarks for delete
using (auth.uid() = user_id);
-- 4. Enable Realtime for the bookmarks table
alter publication supabase_realtime add table public.bookmarks;