-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
33 lines (29 loc) · 998 Bytes
/
schema.sql
File metadata and controls
33 lines (29 loc) · 998 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
26
27
28
29
30
31
32
33
-- Table: monitors
create table if not exists monitors (
id uuid primary key default gen_random_uuid(),
user_id uuid references auth.users not null,
name text not null,
url text not null,
method text default 'GET',
is_active boolean default true,
created_at timestamptz default now()
);
-- Table: logs
create table if not exists logs (
id bigint primary key generated always as identity,
monitor_id uuid references monitors on delete cascade,
status_code integer,
latency_ms integer,
timestamp timestamptz default now()
);
-- Enable RLS
alter table monitors enable row level security;
alter table logs enable row level security;
-- RLS Policies for monitors
create policy "Users can manage their own monitors" on monitors
for all using (user_id = auth.uid());
-- RLS Policies for logs
create policy "Users can view logs for their monitors" on logs
for select using (exists (
select 1 from monitors m where m.id = logs.monitor_id and m.user_id = auth.uid()
));