19 lines
638 B
SQL
19 lines
638 B
SQL
create table public.campaigns (
|
|
id uuid primary key default gen_random_uuid(),
|
|
created_at timestamp with time zone not null default now(),
|
|
brand_id uuid not null references public.brands(user_id) on delete cascade,
|
|
description text not null default ''::text
|
|
);
|
|
alter table public.campaigns enable row level security;
|
|
create policy everyone_view_only
|
|
on public.campaigns
|
|
as permissive
|
|
for select
|
|
to authenticated, anon
|
|
using (true);
|
|
create policy users_manage_their_own_data
|
|
on public.campaigns
|
|
as permissive
|
|
for all
|
|
to authenticated
|
|
using ((( SELECT auth.uid() AS uid) = brand_id)); |