Skip to content

feat(store): organization delete keeps the row and frees its name - #1973

Merged
rohilsurana merged 13 commits into
mainfrom
feat/org-row-soft-delete
Oct 13, 2026
Merged

rohilsurana merged 13 commits into
mainfrom
feat/org-row-soft-delete

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What changes

  • Deleting an organization now sets deleted_at on the row instead of removing it. Reads already skip such rows, and the name is free again, so a new org can take it.
  • Two e2e tests cover the result.

Why

The deleter now removes the org's domains and personal access tokens itself (previous PR), so the row no longer has to go for the database cascade to run. Keeping the row also means the foreign keys from billing, projects, groups, invitations and kyc cannot block or fail the delete while those tables move to soft delete.

The org row is still the last step. A failure earlier leaves a live org that can be deleted again.

Depends on

This branch is stacked on the PR that makes the deleter remove domains and tokens before the org row. It also needs the small PR that makes two admin lists (org search and the kyc list) skip deleted orgs, so a deleted org does not show up there.

Side effect

The organization.delete audit record now carries a real delete time. After a hard delete the time was empty.

Not in this PR

The trigger trg_serviceusers_block_org_delete fires on DELETE only, so it stops guarding anything. It is dropped by the service user soft delete work.

Release note

This release starts writing deleted_at on organizations. The read filters for organizations, domains and personal access tokens, and the admin list fix above, must already be deployed in the target environment before this tag goes out. Ship it together with the PR that makes the org delete also remove disabled projects and groups (#1976). Without that PR, an org with a disabled project or group would be soft deleted and those children would stay live. No new migration. Deploy to dev, then staging, then prod.

Tests

  • Repository: org delete keeps the row, hides it from reads, refuses a second delete and frees the name.
  • e2e: after an org delete no live policy names the org, the org is hidden from the superuser list, its domain is gone, a second delete is refused and the name can be reused.
  • e2e: a token of a deleted org is rejected, hidden from its owner, holds no live policy, and no relation is left for it.

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Oct 12, 2026 10:23am UTC

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: raystack/frontier/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 544d285a-c8b4-4703-8846-5590b72959b3
📥 Commits

Reviewing files that changed from the base of the PR and between 58578a2 and 4b13c1e.

📒 Files selected for processing (17)
  • cmd/serve.go
  • core/deleter/mocks/domain_service.go
  • core/deleter/mocks/user_pat_service.go
  • core/deleter/service.go
  • core/deleter/service_test.go
  • core/userpat/mocks/repository.go
  • core/userpat/models/pat.go
  • core/userpat/service.go
  • core/userpat/service_test.go
  • core/userpat/userpat.go
  • internal/store/postgres/organization_repository.go
  • internal/store/postgres/organization_repository_test.go
  • internal/store/postgres/userpat.go
  • internal/store/postgres/userpat_repository.go
  • internal/store/postgres/userpat_repository_test.go
  • test/e2e/regression/api_test.go
  • test/e2e/regression/pat_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

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

@coveralls

coveralls commented Oct 7, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 38235878862

Coverage remained the same at 54.41%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 41450
Covered Lines: 22553
Line Coverage: 54.41%
Coverage Strength: 18.11 hits per line

💛 - Coveralls

@rohilsurana
rohilsurana force-pushed the feat/org-row-soft-delete branch from 614bec4 to 4b13c1e Compare October 12, 2026 10:22
Base automatically changed from feat/deleter-removes-org-domains-and-pats to main October 13, 2026 07:05
@rohilsurana
rohilsurana merged commit caef5be into main Oct 13, 2026
13 checks passed
@rohilsurana
rohilsurana deleted the feat/org-row-soft-delete branch October 13, 2026 07:05

This branch was successfully deployed

1 active deployment
Preview — 4b13c1e5 Deployed Oct 12, 2026 by vercel[bot]
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.

3 participants