From fadfcf3520e7647aee2940059bd5ed1582b15b90 Mon Sep 17 00:00:00 2001 From: Alex Estevez Date: Tue, 17 Oct 2023 22:12:15 -0400 Subject: [PATCH] fixed users id column not referencing auth.users --- setup.sql | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/setup.sql b/setup.sql index 8b31e84..9b9bfa4 100644 --- a/setup.sql +++ b/setup.sql @@ -1,6 +1,6 @@ -- Create a table for users create table users ( - id uuid not null primary key, + id uuid references auth.users not null primary key, email text not null, password text not null ); @@ -85,14 +85,6 @@ create table milestones ( description text ); --- Create a table for public profiles -create table profiles ( - id uuid references users not null primary key, - email text not null unique, - display_name text not null, - biography text -); - -- Set up Row Level Security (RLS) -- See https://supabase.com/docs/guides/auth/row-level-security for more details. alter table profiles enable row level security; @@ -134,9 +126,14 @@ create trigger on_auth_user_created -- ALTER TABLE milestones ENABLE ROW LEVEL SECURITY; -- -- Allow users to view/edit their own data in the patients, clinicians, and admins tables --- create policy "Users can view/ edit their own data." --- on users for select, update --- using (auth.uid() = userId); +-- create policy "Users can view their own data." on users +-- for select using (auth.uid() = userId); + +-- create policy "Patients can view their own data." on patients +-- for select using (auth.uid() = userId); + +-- create policy "Clinicians can view their own data." on patients +-- for select using (auth.uid() = clinicianId); -- -- Allow clinicians to view patient data -- CREATE POLICY "Clinicians can view patient data."