-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
40 lines (34 loc) · 1.21 KB
/
database.sql
File metadata and controls
40 lines (34 loc) · 1.21 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
32
33
34
35
36
37
38
39
40
-- Create Job Descriptions table
create table job_descriptions (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users not null,
title text not null,
tier text,
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);
-- Create Scan History table
create table scan_history (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users not null,
jd_id uuid references job_descriptions(id),
candidate_name text,
score integer,
outreach_draft text,
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);
-- Enable RLS
alter table job_descriptions enable row level security;
alter table scan_history enable row level security;
-- Create policies
create policy "Users can view their own JDs"
on job_descriptions for select
using ( auth.uid() = user_id );
create policy "Users can insert their own JDs"
on job_descriptions for insert
with check ( auth.uid() = user_id );
create policy "Users can view their own history"
on scan_history for select
using ( auth.uid() = user_id );
create policy "Users can insert their own history"
on scan_history for insert
with check ( auth.uid() = user_id );