Skip to content

Conversation

@cathteng
Copy link
Member

We expect all Groups to have a DetectorGroup entry unless the associated detector is deleted. In the latter case we'd prefer to have a record of the association existing but simply set the detector field to null. Then we can confidently say the detector for a group no longer exists.

This also makes it easier when backfilling -- we can distinguish between groups we need to backfill DetectorGroup for and groups that simply no longer have an associated Detector.

@cathteng cathteng requested review from a team as code owners November 14, 2025 00:03
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 14, 2025
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/workflow_engine/migrations/0097_detectorgroup_detector_set_null.py

for 0097_detectorgroup_detector_set_null in workflow_engine

--
-- Alter field detector on detectorgroup
--
SET CONSTRAINTS "workflow_engine_dete_detector_id_0c22c088_fk_workflow_" IMMEDIATE; ALTER TABLE "workflow_engine_detectorgroup" DROP CONSTRAINT "workflow_engine_dete_detector_id_0c22c088_fk_workflow_";
ALTER TABLE "workflow_engine_detectorgroup" ALTER COLUMN "detector_id" DROP NOT NULL;
ALTER TABLE "workflow_engine_detectorgroup" ADD CONSTRAINT "workflow_engine_dete_detector_id_0c22c088_fk_workflow_" FOREIGN KEY ("detector_id") REFERENCES "workflow_engine_detector" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_detectorgroup" VALIDATE CONSTRAINT "workflow_engine_dete_detector_id_0c22c088_fk_workflow_";

@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/workflow_engine/migrations/0098_detectorgroup_detector_set_null.py

for 0098_detectorgroup_detector_set_null in workflow_engine

--
-- Alter field detector on detectorgroup
--
SET CONSTRAINTS "workflow_engine_dete_detector_id_0c22c088_fk_workflow_" IMMEDIATE; ALTER TABLE "workflow_engine_detectorgroup" DROP CONSTRAINT "workflow_engine_dete_detector_id_0c22c088_fk_workflow_";
ALTER TABLE "workflow_engine_detectorgroup" ALTER COLUMN "detector_id" DROP NOT NULL;
ALTER TABLE "workflow_engine_detectorgroup" ADD CONSTRAINT "workflow_engine_dete_detector_id_0c22c088_fk_workflow_" FOREIGN KEY ("detector_id") REFERENCES "workflow_engine_detector" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_detectorgroup" VALIDATE CONSTRAINT "workflow_engine_dete_detector_id_0c22c088_fk_workflow_";

@cathteng cathteng merged commit 8e0fb75 into master Nov 14, 2025
66 of 67 checks passed
@cathteng cathteng deleted the cathy/aci/detectorgroup-detector-set-null branch November 14, 2025 21:53
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.

3 participants