feat: enable maintainers processing for all git, github, and gitlab repos instead of github only (CM-773)#3594
Conversation
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
| @@ -0,0 +1,7 @@ | |||
| -- Migration to remove the foreign key constraint from maintainersInternal.repoId to githubRepos.id | |||
| -- This removes the dependency on githubRepos table | |||
There was a problem hiding this comment.
why not have both migrations in one?
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| ADD CONSTRAINT "maintainersInternal_repoId_fkey" | ||
| FOREIGN KEY ("repoId") | ||
| REFERENCES git.repositories(id) | ||
| ON DELETE CASCADE; No newline at end of file |
There was a problem hiding this comment.
Bug: Foreign Key Migration Requires Data Synchronization
The migration adds a foreign key constraint referencing git.repositories(id) without ensuring all repoId values in maintainersInternal exist in git.repositories. If any maintainer records reference repos that haven't been synced from githubRepos to git.repositories yet, the constraint addition will fail with a foreign key violation. The migration needs a preceding data migration to populate git.repositories with all repos currently referenced by maintainersInternal before changing the constraint.
| ADD CONSTRAINT "maintainersInternal_repoId_fkey" | ||
| FOREIGN KEY ("repoId") | ||
| REFERENCES git.repositories(id) | ||
| ON DELETE CASCADE; No newline at end of file |
There was a problem hiding this comment.
Bug: Materialized View Breaks Maintainer Processing
The migration changes maintainersInternal.repoId to reference git.repositories but doesn't update the mv_maintainer_roles materialized view, which still joins with githubRepos on repoId. This breaks the PR's stated goal of processing maintainers for all Git, GitHub, and GitLab repos, as the view will only show repos that exist in githubRepos. The view needs to be recreated to join with git.repositories instead.
This pull request updates the foreign key relationship for the
maintainersInternaltable to reference the newgit.repositoriestable instead of the oldgithubRepostable. The changes are implemented through two database migrations: one to remove the old foreign key and another to add the new one.The end goal is to be able to process maintainers for all Git, GitHub, and GitLab repos instead of GitHubRepos only
Database schema migration:
maintainersInternal.repoIdtogithubRepos.id, eliminating the dependency on thegithubRepostable.maintainersInternal.repoIdtogit.repositories.id, establishing the updated relationship and enabling cascading deletes.Note
Updates
maintainersInternal.repoIdforeign key to referencegit.repositories(id)with cascade delete, removing oldgithubReposFK.maintainersInternal_repoId_fkeytogithubRepos.id.maintainersInternal.repoIdtogit.repositories(id)withON DELETE CASCADE.Written by Cursor Bugbot for commit 0ecd9ec. This will update automatically on new commits. Configure here.