BEGIN; -- Audit evidence must survive an account deletion, but it must not block the -- deletion or retain a recoverable administrator identity. Existing audit_log -- rows are preserved; only the actor reference becomes NULL on deletion. ALTER TABLE public.audit_log ALTER COLUMN admin_id DROP NOT NULL; ALTER TABLE public.audit_log DROP CONSTRAINT IF EXISTS audit_log_admin_id_fkey; ALTER TABLE public.audit_log ADD CONSTRAINT audit_log_admin_id_fkey FOREIGN KEY (admin_id) REFERENCES auth.users(id) ON DELETE SET NULL; COMMIT;