fix(migration): exclude _skills sentinel from F2 cross-org verify#57
Merged
Conversation
The git_repositories composite-unique (F2) migration aborts startup if any project_id spans multiple orgs. But the per-org skills sentinel (SkillsRepoSentinelProjectID = "_skills") is one row per org by design, so it legitimately spans every org. On any deployment where >=2 orgs have a skills repo, the verify guard miscounts the sentinel as a cross-org collision and os.Exit(1)s the BFF into CrashLoopBackOff. Exclude the sentinel from the verify query so only real project repos are checked against the old global-unique invariant before it is dropped. No data change; the DB is already in the target end-state (composite unique present, global unique already absent). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
app-factory-api(BFF) is in CrashLoopBackOff on thecloud-cpdev cluster. It dies during the startup DB migration, not at runtime:main.gotreats the migration error as fatal (os.Exit(1)) → crash loop.Root cause
The F2 migration (
git_repo_composite_unique.go) replaces the globalUNIQUE(project_id)with compositeUNIQUE(org_id, project_id)via expand → verify → contract. The verify step aborts if anyproject_idspans multiple orgs, on the assumption "the old global unique guaranteed it cannot."That assumption is false because of the skills sentinel: the skills feature stores one
git_repositoriesrow per org withproject_id = "_skills"(models.SkillsRepoSentinelProjectID), created lazily byensureSkillsRepo. So_skillslegitimately spans every org. Once ≥2 orgs have a skills repo, the verify guard miscounts the sentinel as a cross-org collision and aborts forever — no data fix helps, since per-org_skillsis by design and gets re-created on use.Confirmed on the dev DB: the only spanning value is
_skills(orgsanjana112,anjanas), and the table is already in the target end-state — composite uniqueux_git_repositories_org_projectpresent, old global uniqueidx_git_repositories_project_idalready absent. The expand/contract steps are no-ops; only the verify guard blocks startup.Fix
Exclude the sentinel from the verify query (
WHERE project_id <> models.SkillsRepoSentinelProjectID). Real project-repo collisions are still caught and still abort. No data change.Testing
go build ./database/migrations/passes.🤖 Generated with Claude Code