chore(repositories): Remove project and repo columns from SeerProjectRepository and RepositoryProjectPathConfig#115663
Conversation
340582d to
bcb7d08
Compare
bcb7d08 to
3a08804
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Alter unique_together for repositoryprojectpathconfig (0 constraint(s))
--
ALTER TABLE "sentry_repositoryprojectpathconfig" DROP CONSTRAINT "sentry_repositoryproject_project_id_stack_root_so_c371dfa7_uniq";
--
-- Alter field project on repositoryprojectpathconfig
--
ALTER TABLE "sentry_repositoryprojectpathconfig" ALTER COLUMN "project_id" DROP NOT NULL;
--
-- Alter field repository on repositoryprojectpathconfig
--
SET CONSTRAINTS "sentry_repositorypro_repository_id_e5400943_fk_sentry_re" IMMEDIATE; ALTER TABLE "sentry_repositoryprojectpathconfig" DROP CONSTRAINT "sentry_repositorypro_repository_id_e5400943_fk_sentry_re";
ALTER TABLE "sentry_repositoryprojectpathconfig" ALTER COLUMN "repository_id" DROP NOT NULL;
--
-- Moved repositoryprojectpathconfig.project field to pending deletion state
--
-- (no-op)
--
-- Moved repositoryprojectpathconfig.repository field to pending deletion state
--
-- (no-op)for --
-- Alter unique_together for seerprojectrepository (0 constraint(s))
--
ALTER TABLE "seer_projectrepository" DROP CONSTRAINT "seer_projectrepository_project_id_repository_id_f08c56d6_uniq";
--
-- Alter field project on seerprojectrepository
--
SET CONSTRAINTS "seer_projectrepository_project_id_9b6ca557_fk_sentry_project_id" IMMEDIATE; ALTER TABLE "seer_projectrepository" DROP CONSTRAINT "seer_projectrepository_project_id_9b6ca557_fk_sentry_project_id";
ALTER TABLE "seer_projectrepository" ALTER COLUMN "project_id" DROP NOT NULL;
--
-- Alter field repository on seerprojectrepository
--
SET CONSTRAINTS "seer_projectreposito_repository_id_1c1c52ec_fk_sentry_re" IMMEDIATE; ALTER TABLE "seer_projectrepository" DROP CONSTRAINT "seer_projectreposito_repository_id_1c1c52ec_fk_sentry_re";
ALTER TABLE "seer_projectrepository" ALTER COLUMN "repository_id" DROP NOT NULL;
--
-- Moved seerprojectrepository.project field to pending deletion state
--
-- (no-op)
--
-- Moved seerprojectrepository.repository field to pending deletion state
--
-- (no-op) |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25898b6. Configure here.
| SeerProjectRepository, | ||
| {"project_repository__project_id": instance.id}, | ||
| BulkModelDeletionTask, | ||
| ) |
There was a problem hiding this comment.
Project deletion fails with branch override FK violation
High Severity
When deleting a project, SeerProjectRepository is deleted via BulkModelDeletionTask, which performs a raw SQL DELETE bypassing Django's ORM cascade. However, SeerProjectRepositoryBranchOverride rows referencing those SeerProjectRepository rows are never explicitly deleted first. Since Django creates FK constraints as NO ACTION (not ON DELETE CASCADE) at the database level, the raw DELETE will raise an IntegrityError if any SeerProjectRepositoryBranchOverride rows exist. Previously, SeerProjectRepository had a direct project FK, so Django's ORM cascade from Project.delete() handled the entire chain automatically. Now that the FK is removed, explicit deletion of SeerProjectRepositoryBranchOverride before SeerProjectRepository is needed.
Reviewed by Cursor Bugbot for commit 25898b6. Configure here.
0190e8d to
c1eaea1
Compare
…ojectRepository` and `RepositoryProjectPathConfig` This cleans up writes and any remaining queries to `project` and `repo in `SeerProjectRepository` and `RepositoryProjectPathConfig`, and also removes all references to the columns to prepare for deletion.
- Fix project deletion: RepositoryProjectPathConfig and SeerProjectRepository no longer have project_id, use project_repository__project_id join instead - Fix test files accessing .repository on RepositoryProjectPathConfig, now goes through .project_repository.repository - Fix migration state: keep constraint from 1097, drop unique_together to empty Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
- sentry 1098: Let AlterUniqueTogether run normally to drop the old (project, stack_root, source_root) constraint from the DB - seer 0016: Use state-only AlterUniqueTogether because 0014's AlterField with unique=True already dropped the old constraint Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
…tion The old (project, repository) unique constraint exists in production and needs to be dropped by the migration. The sqlmigrate error on fresh DBs is a false alarm — Django's from-scratch replay doesn't create the old constraint, but production has it. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
c1eaea1 to
9626772
Compare
Phase 2 of `SafeRemoveField`: drop the `project_id` and `repository_id` columns from `sentry_repositoryprojectpathconfig` and `seer_projectrepository`. Phase 1 (`MOVE_TO_PENDING`) was deployed in #115663.


This cleans up writes and any remaining queries to
projectandrepo inSeerProjectRepositoryandRepositoryProjectPathConfig`, and also removes all references to the columns to prepare for deletion.