-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (25 loc) · 1.04 KB
/
Copy pathschema.sql
File metadata and controls
31 lines (25 loc) · 1.04 KB
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
30
31
-- schema.sql
-- Run this code in the Supabase SQL Editor to set up your database.
-- 1. Create the Projects table
create table public.projects (
id uuid default gen_random_uuid() primary key,
title text default 'Untitled',
content jsonb default '[]',
updated_at timestamp with time zone default timezone('utc'::text, now()) not null,
user_id uuid references auth.users not null -- Optional: links script to a user
);
-- 2. Enable Row Level Security (Security Policy)
alter table public.projects enable row level security;
-- 3. Create Policies (This ensures users can only edit their own work)
create policy "Users can view their own projects"
on projects for select
using ( auth.uid() = user_id );
create policy "Users can create their own projects"
on projects for insert
with check ( auth.uid() = user_id );
create policy "Users can update their own projects"
on projects for update
using ( auth.uid() = user_id );
create policy "Users can delete their own projects"
on projects for delete
using ( auth.uid() = user_id );