feat(store): user, organization, and project reads skip soft-deleted rows - #1931
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughChangesPostgreSQL repositories now exclude soft-deleted organizations, projects, and users from reads and updates. Shared helpers add Soft-delete filtering
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Supported reads and updates consistently exclude soft-deleted records, with no remaining merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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 |
Coverage Report for CI Build 35321254518Coverage increased (+0.07%) to 50.306%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
Added a second commit after a live test run against the branch found that
|
|
Tested live on a local server built from this branch. Fixtures: 3 users, 2 orgs, 2 projects. Ran every affected RPC before and after setting
Seen but out of scope here, lands in later PRs:
|
…rows Adds two helpers next to the shared goqu dialect. live(table) is the deleted_at IS NULL filter, qualified with the table name so it stays correct inside joins. fromLive(table) is dialect.From(table) with that filter applied. Every read in the user, organization, and project repositories now goes through fromLive. The four updates keyed by name or email instead of id also add the filter, so a deleted row that shares a name with a live one is never updated by mistake. No row has deleted_at set today, so nothing changes for callers. This must be deployed everywhere before any soft-delete write ships.
UpdateByID and SetState on users, organizations, and projects filtered only on the id. A soft-deleted row could still be written to. Each now adds the live filter, so the update matches nothing and reports not found, the same way a read does. Project SetState runs a plain exec and does not report a miss, so its test checks the row's state directly instead of expecting an error.
…versions Project SetState ran a plain exec and returned nil whether or not a row matched. Its no-rows branch could never fire and returned the user sentinel. It now returns the updated row and maps a miss to project.ErrNotExist, the same shape as the user and organization SetState.
9096e51 to
121181c
Compare
Soft delete keeps a row and sets
deleted_at. Reads have to skip those rows. This is the first of three PRs that make the identity repositories do that.What
postgres.go:live(table)is thedeleted_at IS NULLfilter,fromLive(table)isdialect.Fromwith it applied.fromLive.livefilter too, so a deleted row is never written to.Behaviour change
None today. No row has
deleted_atset yet. This must reach every environment before any release that writesdeleted_at.Tested
One new test per repository: soft-delete a seeded row, then check every get, list, and update skips it. Store package passes with
-race. Verified live against the sandbox twice.