Repository navigation
feat(store): kyc row is kept when an org is deleted - #1984
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
📝 Summary
Merge Risk: 🔵 Low · up to
|
Coverage Report for CI Build 38355103471Coverage increased (+0.02%) to 54.704%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
Note for reviewers about the This PR makes sure every read and write of the kyc table skips deleted kyc rows. It also makes One part is left on purpose and comes with #1974, which is stacked on this PR:
#1974 also adds the live checks to the billing joins of the admin org search. Merge order: #1973 first (see the PR description), then this PR, then #1974. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: raystack/frontier/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cc3a0b77-dba8-414b-885c-adaa6dfd64bf
📒 Files selected for processing (4)
internal/store/postgres/kyc_repository.gointernal/store/postgres/kyc_repository_test.gointernal/store/postgres/migrations/20261012100000_kyc_org_id_live_unique.down.sqlinternal/store/postgres/migrations/20261012100000_kyc_org_id_live_unique.up.sql
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: raystack/frontier/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
52c59f01-f65d-4da8-9200-c49001423f41
📒 Files selected for processing (2)
internal/store/postgres/kyc_repository.gointernal/store/postgres/kyc_repository_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
What changes
The org delete now keeps the KYC row and sets
deleted_at, like the other tables the org delete touches.organizations_kyc.org_idunique over live rows only. The old plain unique constraint is dropped. This lets an org get a new KYC row after the old one was deleted.GetByOrgIDreads live rows only. The update path ofUpsertonly touches the live row.Upsertrefuses an org that is soft deleted or missing. It returnsErrOrgDoesntExistand writes nothing.Deleteis now a soft delete. It still returns success for an org with no KYC row, and a second delete keeps the first delete time.Why
If an org delete stops right after the KYC step, the org is still live but its KYC status and link are gone. With a soft delete the row is kept for audit and Metabase, like the other tables. This came out of the review on #1974.
Merge order
Merge this PR after #1973 (the org row soft delete).
organizations_kyc.org_idhas a foreign key toorganizations(id)with no delete rule. While the org row is still hard deleted, a kept KYC row makes the org delete fail on that key on every retry.Merge this PR before #1974. #1974 is stacked on this one and changes the same list query.
Down migration
The down migration adds the plain unique constraint back. It fails if an org has both a deleted and a live KYC row. That can only happen after this change is in use.
Tests
Upsertafter a delete creates a new live row.Upserton a soft deleted org is refused, for a first insert and for an org with an existing KYC row. Nothing is written and no audit record is added.