25 lines
986 B
SQL
25 lines
986 B
SQL
create table "audit"."page_views" (
|
|
"id" bigint generated by default as identity not null,
|
|
"account_id" text not null,
|
|
"action" text not null,
|
|
"created_at" timestamp with time zone not null default now(),
|
|
"changed_by" uuid not null
|
|
);
|
|
|
|
grant usage on schema audit to authenticated;
|
|
grant select, insert, update, delete on table audit.page_views to authenticated;
|
|
|
|
alter table "audit"."page_views" enable row level security;
|
|
|
|
create policy "insert_own"
|
|
on "audit"."page_views"
|
|
as permissive
|
|
for insert
|
|
to authenticated
|
|
with check (auth.uid() = changed_by);
|
|
|
|
create policy "service_role_select" on "audit"."page_views" for select to service_role using (true);
|
|
create policy "service_role_insert" on "audit"."page_views" for insert to service_role with check (true);
|
|
create policy "service_role_update" on "audit"."page_views" for update to service_role using (true);
|
|
create policy "service_role_delete" on "audit"."page_views" for delete to service_role using (true);
|