-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
25 lines (19 loc) · 994 Bytes
/
init.sql
File metadata and controls
25 lines (19 loc) · 994 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
-- Create bookmarks table
create table bookmarks (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users not null,
title text not null,
url text not null,
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);
-- Enable RLS
alter table bookmarks enable row level security;
-- Policies
-- Allow users to view their own bookmarks
create policy "Users can view their own bookmarks." on bookmarks for select using (auth.uid() = user_id);
-- Allow users to insert their own bookmarks
create policy "Users can insert their own bookmarks." on bookmarks for insert with check (auth.uid() = user_id);
-- Allow users to delete their own bookmarks
create policy "Users can delete their own bookmarks." on bookmarks for delete using (auth.uid() = user_id);
-- Bonus: Allow users to update their own bookmarks (just in case)
create policy "Users can update their own bookmarks." on bookmarks for update using (auth.uid() = user_id);