Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ tempest: 0001_squashed_0002_make_message_type_nullable

uptime: 0048_delete_uptime_status_columns

workflow_engine: 0094_backfill_issue_stream_detector_workflows
workflow_engine: 0095_unique_detectorgroup_group
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 5.2.1 on 2025-11-06 22:43

import django.db.models.deletion
from django.db import migrations

import sentry.db.models.fields.foreignkey
from sentry.new_migrations.migrations import CheckedMigration


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# This should only be used for operations where it's safe to run the migration after your
# code has deployed. So this should not be used for most operations that alter the schema
# of a table.
# Here are some things that make sense to mark as post deployment:
# - Large data migrations. Typically we want these to be run manually so that they can be
# monitored and not block the deploy for a long period of time while they run.
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = True

dependencies = [
("sentry", "1003_group_history_prev_history_safe_removal"),
("workflow_engine", "0094_backfill_issue_stream_detector_workflows"),
]

operations = [
migrations.AlterField(
model_name="detectorgroup",
name="group",
field=sentry.db.models.fields.foreignkey.FlexibleForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="sentry.group", unique=True
),
),
migrations.AlterUniqueTogether(
name="detectorgroup",
unique_together=set(),
),
]
3 changes: 1 addition & 2 deletions src/sentry/workflow_engine/models/detector_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class DetectorGroup(DefaultFieldsModel):
__relocation_scope__ = RelocationScope.Excluded

detector = FlexibleForeignKey("workflow_engine.Detector", on_delete=models.CASCADE)
group = FlexibleForeignKey("sentry.Group", on_delete=models.CASCADE)
group = FlexibleForeignKey("sentry.Group", on_delete=models.CASCADE, unique=True)

class Meta:
db_table = "workflow_engine_detectorgroup"
app_label = "workflow_engine"
unique_together = (("detector", "group"),)
Copy link
Member

Choose a reason for hiding this comment

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

I think we're safe enough without this index. If we search on detector_id, group_id it can just use the unique on group. The only case I can think of where this old index might have been helpful if we did where detector_id = x order by group_id, which doesn't seem like it'd happen too often

indexes = [
models.Index(fields=["detector", "-date_added"], name="detectorgroup_det_date_idx"),
]
Loading