-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
63 lines (52 loc) · 2.12 KB
/
schema.sql
File metadata and controls
63 lines (52 loc) · 2.12 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Enable UUID extension
create extension if not exists "uuid-ossp";
-- Create candidates table
create table public.candidates (
id uuid default uuid_generate_v4() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
name text not null,
email text not null,
phone text,
status text check (status in ('in_progress', 'hired', 'rejected')) default 'in_progress',
user_id uuid references auth.users not null default auth.uid()
);
-- Create interviews table
create table public.interviews (
id uuid default uuid_generate_v4() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
candidate_id uuid references public.candidates(id) on delete cascade not null,
round_type text check (round_type in ('technical', 'hr', 'director')) not null,
round_index integer default 1, -- For multiple technical rounds
score numeric,
feedback text,
user_id uuid references auth.users not null default auth.uid()
);
-- Enable RLS
alter table public.candidates enable row level security;
alter table public.interviews enable row level security;
-- Policies for candidates
create policy "Users can view their own candidates"
on public.candidates for select
using (auth.uid() = user_id);
create policy "Users can insert their own candidates"
on public.candidates for insert
with check (auth.uid() = user_id);
create policy "Users can update their own candidates"
on public.candidates for update
using (auth.uid() = user_id);
create policy "Users can delete their own candidates"
on public.candidates for delete
using (auth.uid() = user_id);
-- Policies for interviews
create policy "Users can view their own interviews"
on public.interviews for select
using (auth.uid() = user_id);
create policy "Users can insert their own interviews"
on public.interviews for insert
with check (auth.uid() = user_id);
create policy "Users can update their own interviews"
on public.interviews for update
using (auth.uid() = user_id);
create policy "Users can delete their own interviews"
on public.interviews for delete
using (auth.uid() = user_id);