0017_user_deletion.sql 774 B

1234567891011121314
  1. -- 0017_user_deletion — adds the deletion_reason column so the audit
  2. -- trail can carry a (short, optional) free-text justification the user
  3. -- supplies when they click "delete account". `deleted_at` already
  4. -- exists on users (migration 0001); this only adds the reason field.
  5. ALTER TABLE "users"
  6. ADD COLUMN IF NOT EXISTS "deletion_reason" text;
  7. -- Pseudonymise PII once a row is soft-deleted: email + audit-log FKs
  8. -- survive (so admin can correlate post-deletion incidents), but legal
  9. -- name / address / VAT / company name / display name / image all clear
  10. -- inside the same transaction the service runs. No DB-side trigger —
  11. -- the service is the only path that touches deletion, and a trigger
  12. -- would make the hard-delete cron's logic harder to reason about.