Skip to content

Simplify dormant checkout stage cleanup - #1848

Merged
stefan-burke merged 4 commits into
mainfrom
split/checkout-stage-simplify
Jul 17, 2026
Merged

Simplify dormant checkout stage cleanup#1848
stefan-burke merged 4 commits into
mainfrom
split/checkout-stage-simplify

Conversation

@stefan-burke

@stefan-burke stefan-burke commented Jul 16, 2026

Copy link
Copy Markdown
Member

What changed

  • Keep only the dormant checkout stage table and remove its unused revision counter and triggers.
  • Remove checkout stages when an attendee is deleted or cleared as an orphan.
  • Remove both checkout stages when two attendees are merged because neither saved snapshot is valid afterward.
  • Keep processed payment records during a merge.
  • Add a safe, repeatable migration that removes the old revision storage from sites that already received it.

Checkout and payment runtime remain disabled. Open checkout stages are temporary and do not need to survive deploys, host moves, restores, attendee deletion, or attendee merges. This change does not alter backup, export, or restore behavior.

Checks

  • Regression tests first confirmed all three cleanup paths left stage rows behind.
  • Focused checkout stage, attendee deletion, orphan purge, merge, migration, and registry tests pass.
  • nix develop -c deno task precommit passes.
  • nix develop -c deno task precommit:mutation passes with 541 of 541 detectable mutants killed.

Summary by CodeRabbit

  • Bug Fixes
    • Attendee deletion now also removes associated checkout-stage records.
    • Orphan purging and attendee merges now clean up checkout-stage records.
    • Merged payment records continue to be preserved and reassigned correctly.
  • Database Updates
    • Removed legacy checkout-stage revision tracking and its triggers.
    • Migration registry and schema updates now retain only checkout-stage storage.
  • Tests
    • Added/updated checkout-stage cleanup tests for deletion, purge, and merge flows.
    • Updated migration and schema guard coverage for the revision drop.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6ba7e9d3-93c2-402a-8b45-6f6d17016b5c

📥 Commits

Reviewing files that changed from the base of the PR and between cebaa33 and e1c8998.

📒 Files selected for processing (1)
  • test/shared/db/orphan-attendees.test.ts

📝 Walkthrough

Walkthrough

Checkout-stage rows are added to attendee deletion, orphan purging, and attendee merging cleanup paths. Checkout-stage revision tables and triggers are removed from the schema and deleted through a registered migration, with updated migration and integration tests.

Changes

Checkout stage cleanup

Layer / File(s) Summary
Dependent-row cleanup flow
src/shared/db/attendees/delete.ts, src/shared/merge/attendee-merge.ts, test/...
Parameterized dependent-row deletion now includes checkout_stages; attendee deletion, orphan purging, and attendee merging remove checkout-stage rows.
Checkout-stage schema transition
src/shared/db/migrations/..., src/shared/db/migrations/schema/...
The schema retains dormant checkout_stages storage while removing revision-table and revision-trigger declarations; a follow-up migration drops legacy objects.
Migration and schema validation
test/lib/db/..., test/shared/...
Tests validate cleanup, migration repeatability, absent legacy objects, migration registration, schema hashes, and restore coverage.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AttendeeOperation
  participant DependentDeleteSQL
  participant CheckoutStages
  AttendeeOperation->>DependentDeleteSQL: build deletion for attendee IDs
  DependentDeleteSQL->>CheckoutStages: delete matching checkout-stage rows
  CheckoutStages-->>AttendeeOperation: cleanup completes
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: simplifying dormant checkout stage cleanup by removing legacy revisions and adding cleanup paths.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split/checkout-stage-simplify

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@test/shared/db/orphan-attendees.test.ts`:
- Around line 155-161: Update the childCount helper used by the “removes the
orphan's checkout stage” test to require that the COUNT(*) query returns an
aggregate row, rather than converting a missing row to 0. Keep returning the
row’s count for valid results so the assertion remains capable of detecting the
checkout-stage deletion.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a45fb58a-f899-433a-acd4-75d71b84a536

📥 Commits

Reviewing files that changed from the base of the PR and between 2317bc7 and 9d62c21.

📒 Files selected for processing (15)
  • src/shared/db/attendees/delete.ts
  • src/shared/db/migrations/2026-07-15_checkout_stages.ts
  • src/shared/db/migrations/2026-07-16_drop_checkout_stage_revisions.ts
  • src/shared/db/migrations/registry.ts
  • src/shared/db/migrations/schema/checkout-stage-triggers.ts
  • src/shared/db/migrations/schema/tables-attendees.ts
  • src/shared/db/migrations/schema/triggers.ts
  • src/shared/merge/attendee-merge.ts
  • test/lib/db/attendees/delete-attendee.test.ts
  • test/lib/db/checkout-stage-schema.test.ts
  • test/lib/db/migration-restore/verify.test.ts
  • test/lib/db/migration-schema-guard.test.ts
  • test/shared/db/orphan-attendees.test.ts
  • test/shared/merge/attendee-merge/checkout-stage-cleanup.test.ts
  • test/test-utils/checkout-stages.ts
💤 Files with no reviewable changes (3)
  • src/shared/db/migrations/schema/checkout-stage-triggers.ts
  • src/shared/db/migrations/schema/tables-attendees.ts
  • src/shared/db/migrations/schema/triggers.ts

Comment thread test/shared/db/orphan-attendees.test.ts
@stefan-burke
stefan-burke added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit 892b4f2 Jul 17, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the split/checkout-stage-simplify branch July 17, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant