Skip to content

chore(repositories): Add a table to allow us to link a project to a repository#115331

Open
wedamija wants to merge 5 commits into
masterfrom
danf/repository-project-link
Open

chore(repositories): Add a table to allow us to link a project to a repository#115331
wedamija wants to merge 5 commits into
masterfrom
danf/repository-project-link

Conversation

@wedamija
Copy link
Copy Markdown
Member

@wedamija wedamija commented May 11, 2026

This adds in ProjectRepository, which will allow us to more explicitly link a project to a repository. We also have a source column, so we can determine whether the link was detected automatically or added by a user explicitly.

Also adds links to this new table in seer and code mappings

@wedamija wedamija requested review from a team as code owners May 11, 2026 21:29
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 11, 2026
@github-actions

This comment was marked as outdated.

@wedamija wedamija requested review from a team as code owners May 11, 2026 21:38
Comment thread src/sentry/integrations/models/repository_project_path_config.py
Comment thread src/sentry/integrations/models/repository_project_path_config.py
Comment thread src/sentry/integrations/models/repository_project_path_config.py
Comment thread src/sentry/seer/models/project_repository.py
@wedamija wedamija force-pushed the danf/repository-project-link branch from d4f5722 to 8312052 Compare May 11, 2026 22:30
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/1086_add_projectrepository.py src/sentry/seer/migrations/0011_add_project_repository_fk_to_seer.py

for 1086_add_projectrepository in sentry

--
-- Create model ProjectRepository
--
CREATE TABLE "sentry_projectrepository" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "source" smallint NOT NULL, "project_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
--
-- Add field project_repository to repositoryprojectpathconfig
--
ALTER TABLE "sentry_repositoryprojectpathconfig" ADD COLUMN "project_repository_id" bigint NULL;
CREATE UNIQUE INDEX CONCURRENTLY "sentry_projectrepository_project_id_repository_id_baccce58_uniq" ON "sentry_projectrepository" ("project_id", "repository_id");
ALTER TABLE "sentry_projectrepository" ADD CONSTRAINT "sentry_projectrepository_project_id_repository_id_baccce58_uniq" UNIQUE USING INDEX "sentry_projectrepository_project_id_repository_id_baccce58_uniq";
ALTER TABLE "sentry_projectrepository" ADD CONSTRAINT "sentry_projectreposi_project_id_15b94027_fk_sentry_pr" FOREIGN KEY ("project_id") REFERENCES "sentry_project" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_projectrepository" VALIDATE CONSTRAINT "sentry_projectreposi_project_id_15b94027_fk_sentry_pr";
ALTER TABLE "sentry_projectrepository" ADD CONSTRAINT "sentry_projectreposi_repository_id_46f90b5f_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_projectrepository" VALIDATE CONSTRAINT "sentry_projectreposi_repository_id_46f90b5f_fk_sentry_re";
CREATE INDEX CONCURRENTLY "sentry_projectrepository_project_id_15b94027" ON "sentry_projectrepository" ("project_id");
CREATE INDEX CONCURRENTLY "sentry_projectrepository_repository_id_46f90b5f" ON "sentry_projectrepository" ("repository_id");
ALTER TABLE "sentry_repositoryprojectpathconfig" ADD CONSTRAINT "sentry_repositorypro_project_repository_i_3e830ad9_fk_sentry_pr" FOREIGN KEY ("project_repository_id") REFERENCES "sentry_projectrepository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_repositoryprojectpathconfig" VALIDATE CONSTRAINT "sentry_repositorypro_project_repository_i_3e830ad9_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "sentry_repositoryprojectpa_project_repository_id_3e830ad9" ON "sentry_repositoryprojectpathconfig" ("project_repository_id");

for 0011_add_project_repository_fk_to_seer in seer

--
-- Add field project_repository to seerprojectrepository
--
ALTER TABLE "seer_projectrepository" ADD COLUMN "project_repository_id" bigint NULL;
ALTER TABLE "seer_projectrepository" ADD CONSTRAINT "seer_projectreposito_project_repository_i_bff6d0fe_fk_sentry_pr" FOREIGN KEY ("project_repository_id") REFERENCES "sentry_projectrepository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_projectrepository" VALIDATE CONSTRAINT "seer_projectreposito_project_repository_i_bff6d0fe_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "seer_projectrepository_project_repository_id_bff6d0fe" ON "seer_projectrepository" ("project_repository_id");

@wedamija wedamija requested a review from a team May 11, 2026 23:24
wedamija added 4 commits May 11, 2026 16:56
…epository

This adds in `ProjectRepository`, which will allow us to more explicitly link a project to a repository. We also have a `source` column, so we can determine whether the link was detected automatically or added by a user explicitly.
@wedamija wedamija force-pushed the danf/repository-project-link branch from 8312052 to 9fdecb2 Compare May 11, 2026 23:57
Comment thread src/sentry/seer/migrations/0011_add_project_repository_fk_to_seer.py Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9fdecb2. Configure here.

Comment thread src/sentry/seer/migrations/0011_add_project_repository_fk_to_seer.py Outdated
The sentry migration was renumbered from 1086 to 1087 after a rebase,
but the seer migration still referenced the old number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants