venthrive-api / sql /admin_audit_schema.sql
GitHub Actions
Sync from GitHub · 2026-10-22 20:43 UTC
89a70e2
Raw History Blame Contribute Delete
1.4 kB
-- Admin audit trail — every manual admin action (review decisions, source
-- toggles, poll runs), newest first. Mirrors DataWiz-Project's /admin/audit.
-- Automatic pipeline decisions (auto-publish, auto-discard) are NOT logged
-- here — they're already visible per-item in news_items.status, and logging
-- every one of them would make this table useless as a human-action trail.
create extension if not exists pgcrypto;
create table if not exists admin_audit_log (
id uuid primary key default gen_random_uuid(),
at timestamptz not null default now(),
actor text not null, -- admin's Firebase UID
kind text not null check (kind in ('review', 'source', 'run', 'niche')),
action text not null, -- e.g. 'published', 'discarded', 'enabled', 'disabled', 'started'
target text, -- the item/source/poll id this action was on
summary text not null -- short human-readable description, e.g. the item title
);
create index if not exists admin_audit_log_at_idx on admin_audit_log (at desc);
-- 2026-10-22: niche requests (marking a missing niche added/dismissed) are
-- audited too. For a table created before this date, run:
alter table admin_audit_log drop constraint if exists admin_audit_log_kind_check;
alter table admin_audit_log add constraint admin_audit_log_kind_check
check (kind in ('review', 'source', 'run', 'niche'));