Create moderation reports table
cgen-9461dd9ce64f4c7698c8ca08eafad552
This commit is contained in:
parent
84d80afce2
commit
29885683fe
1 changed files with 28 additions and 0 deletions
28
supabase/migrations/20251018_moderation_reports.sql
Normal file
28
supabase/migrations/20251018_moderation_reports.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
create extension if not exists "pgcrypto";
|
||||
|
||||
create table if not exists public.moderation_reports (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
reporter_id uuid references public.user_profiles(id) on delete set null,
|
||||
target_type text not null check (target_type in ('post','comment','user','project','other')),
|
||||
target_id uuid,
|
||||
reason text not null,
|
||||
details text,
|
||||
status text not null default 'open' check (status in ('open','resolved','ignored')),
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists moderation_reports_status_idx on public.moderation_reports (status);
|
||||
create index if not exists moderation_reports_target_idx on public.moderation_reports (target_type, target_id);
|
||||
|
||||
create or replace function public.set_updated_at()
|
||||
returns trigger as $$
|
||||
begin
|
||||
new.updated_at = now();
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger moderation_reports_set_updated_at
|
||||
before update on public.moderation_reports
|
||||
for each row execute function public.set_updated_at();
|
||||
Loading…
Reference in a new issue