feat(audit): Sprint 16 §5.1 — deletedBy actor on every soft-deletable model#15
feat(audit): Sprint 16 §5.1 — deletedBy actor on every soft-deletable model#15dobrodob wants to merge 1 commit intofeat/sprint-16-b-observabilityfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
78600c6 to
a0a24e5
Compare
8dfc133 to
2f2a39d
Compare
|
@coderabbitai review — this PR was marked as skipped earlier. Please review explicitly. |
|
🧠 Learnings used✅ Actions performedReview triggered.
|
2f2a39d to
eb2ae06
Compare
8e3c542 to
dddf31f
Compare
eb2ae06 to
1eac3c4
Compare
… model Extends the existing soft-delete foundation (pattern 18) with an audit column: WHO removed the row, not just WHEN. Answers the "who nuked this?" question without spinning up a parallel audit-log table. Schema changes (migration 20260419163543): - Add `deleted_by INT NULL` + FK(SET NULL) to authors, communities, conversations, files, messages, shout_reactions_followers, bookmark_lists. - Promote the pre-existing `deleted_by` int on `drafts` to a typed FK with ON DELETE SET NULL. (Shouts and Reactions already had proper FKs.) - Corresponding Prisma relations + reverse relations on Author (7 new). - Hand-edited migration SQL to strip Prisma-generated `DROP DEFAULT` on tsvector columns — Postgres rejects those on generated columns. Rationale documented in the migration file header. Service wiring: - community.softDelete now takes `actorId: number | null` (explicit typing for system-triggered teardowns — seed scripts, migration cleanup). - bookmark-list / follower / file / message services pass the actor ID on every soft-delete write. - shout / draft / reaction already did (from earlier sprints) — left as-is. Regression guard: - deleted-by-audit.integration.spec.ts — 6 tests, one per service path: soft-delete a row, read it back, assert `deletedBy === actor.id`. Protects against a future refactor silently dropping the actor. Pattern doc: - 43-deleted-by-actor-audit.md — why audit trail lives in-row (not a parallel table), GDPR-friendly SET NULL semantics, adaptation notes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dddf31f to
1e7a5c1
Compare
1eac3c4 to
f9c5db1
Compare
Summary
Sprint 16 §5.1 — extends the existing soft-delete foundation (pattern 18) with an audit column: who removed the row, not just when. Answers the "who nuked this?" question without spinning up a parallel audit-log table.
PR 3 of 7 for Sprint 16 — stacked on top of #14.
Schema changes
Migration `20260419163543_sprint_16_deleted_by_audit`:
Hand-edited migration SQL to strip Prisma-generated `DROP DEFAULT` statements on tsvector columns — Postgres rejects those on generated columns (`column is a generated column`). Rationale documented in the migration file header.
Service wiring
Test plan
Migration notes
Docs
🤖 Generated with Claude Code