Drop legacy APP_DB audit table - #1146
Conversation
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
…d1-0dbb # Conflicts: # docs/contributing/architecture/data-storage.md # packages/worker/src/app/admin-insights-data.ts # packages/worker/src/email/delivery-events.ts # packages/worker/src/email/inbound.ts # packages/worker/src/email/outbound.ts # packages/worker/src/email/service.ts # packages/worker/worker-configuration.d.ts Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
…d1-0dbb Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
…d1-0dbb Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
📝 WalkthroughWalkthroughThe change removes the legacy ChangesAudit storage retirement
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
🔎 Preview deployed: https://kody-pr-1146.kody-a99.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/worker/src/mcp/capabilities/admin/admin-mailbox-maintenance.node.test.ts`:
- Line 135: The test fixture’s env binding currently assigns the same database
to APP_DB and AUDIT_DB, so create separate in-memory databases in the fixture
setup: initialize APP_DB with the users schema and AUDIT_DB with the
audit_events schema, then pass those distinct instances through the env object
while preserving the existing test behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ef4a1ace-e53a-4ee2-ba5c-ec36c463a975
📒 Files selected for processing (8)
docs/contributing/architecture/data-storage.mdpackages/worker/migrations/0127-drop-legacy-audit-events.sqlpackages/worker/src/app/account-retention-dispositions.tspackages/worker/src/app/retention.node.test.tspackages/worker/src/app/retention.tspackages/worker/src/mcp/capabilities/admin/admin-mailbox-maintenance.node.test.tspackages/worker/src/package-registry/test-schema.tstools/migration-ledger.json
💤 Files with no reviewable changes (3)
- packages/worker/src/app/retention.ts
- packages/worker/src/app/retention.node.test.ts
- packages/worker/src/app/account-retention-dispositions.ts
|
@coderabbitai review |
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Summary
audit_eventstable from APP_DB in migration 0127Production evidence
2026-08-01T23:43:04Z— APP_DBaudit_eventstable count=0; AUDIT_DB count=65,519, including all 65,147 historical rows; oldest/newest=2026-07-06T13:21:25Z/2026-08-01T23:34:01Zadmin_audit_log_querysmoke passed after drop (total=65,519, one row returned)Validation
CI=1 npm run validatepassedReview response
CodeRabbit correctly identified that a shared APP_DB/AUDIT_DB fixture could mask a regression. The admin test now provisions distinct databases with only their owned schemas.
System recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@eb21f180· Head:f9bd3f3dClassification: extends — APP_DB removes a duplicate table after every retained row is proven present in the authoritative audit database.
Primitives touched
d1-app-dbaudit_eventstableaudit-d1scheduled-cronSystem map
The contract migration removes the inactive audit table from APP_DB after exact retained-history backfill; all audit behavior remains on AUDIT_DB.
Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).
Invariants
Conductor report
STATUS: done
What shipped: the audit expand/contract cycle is complete. AUDIT_DB is the sole read/write/retention home; 65,147 retained historical rows were backfilled and exactly verified; migration 0127 removed the APP_DB table and stale APP_DB retention inventory; docs describe only the end state.
Production evidence: VERIFIED — post-expand parity 299/299; hourly retention canary deleted; post-cutover APP_DB delta 0 / AUDIT_DB delta +1; exact historical verifier completed for 65,147 rows; after deployment APP_DB table is absent and AUDIT_DB contains 65,519 rows with the full backfill; admin read smoke passed.
Risk self-assessment: medium after verification — destructive only to a proven duplicate; authoritative history and ongoing events are intact in AUDIT_DB.
Merged/deployed: yes — PR #1146 / yes — production deploy.
Scope spill: append-only APP_DB migration plus audit retention inventory/docs/test cleanup; no email, entitlements, vectorize, or index.ts changes.
Summary by CodeRabbit
Data Management
Bug Fixes
Documentation