Repository navigation
feat(deleter): soft-delete the org's domains and tokens before the org row - #1972
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (13)
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 38235880511Coverage decreased (-0.3%) to 54.41%Details
Uncovered Changes
Coverage Regressions287 previously-covered lines in 9 files lost coverage.
Coverage Stats
💛 - Coveralls |
|
Changed the order of the new steps after review (commit ae9a41e). Before, the domains and tokens were removed after the org policies and roles. The org policies include the owner policy. If a domain or token step failed at that point, the org row was still live but the owner had already lost access. A retry then answered permission denied, so only a superuser could finish the delete. Now the domains and tokens go first, right after the invitations and kyc steps and before the org policies. A failure in either step leaves the org owned, and the owner can run the delete again. Nothing forces the old order. The domain delete only needs the org row, and removing a token's policies does not depend on the org policies. The order is now: other children, domains, tokens, org policies, roles, and the org row last. The order test and the failure tests are updated. A new test covers a failed domain list. |
3451185 to
f1f44cb
Compare
ae9a41e to
eec1053
Compare
|
Same case as the token loop in #1971: if someone deletes a domain while the org delete runs, |
eec1053 to
d4aeb36
Compare
d4aeb36 to
9218314
Compare
|
Fixed in 14f0cf1. The domain loop now skips |
What changes
DeleteAllByOrgfrom the PR below.DomainServiceinterface and aDeleteAllByOrgmethod on its token interface.cmd/serve.gopasses the domain service in.Why
Today the database removes the domains and tokens through
ON DELETE CASCADEwhen the org row goes. The next PR makes the org row delete soft, and a soft delete never triggers the cascade. This PR makes the code do that work first, so there is no point where domains or tokens stay live.This PR is safe on its own. With the current hard delete, the domains and tokens are now removed one step earlier by the code instead of by the cascade.
Depends on
The PR that adds
DeleteAllByOrgto the token service. This branch is stacked on it.Tests