From b4bbeff47a3eeaef673d3f63f20c61dcf5f0835e Mon Sep 17 00:00:00 2001 From: Josh Callender <1569818+saponifi3d@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:47:58 -0800 Subject: [PATCH 1/2] Add an index to the incident group open period --- src/sentry/workflow_engine/models/incident_groupopenperiod.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sentry/workflow_engine/models/incident_groupopenperiod.py b/src/sentry/workflow_engine/models/incident_groupopenperiod.py index 3415742b404253..049998f192b558 100644 --- a/src/sentry/workflow_engine/models/incident_groupopenperiod.py +++ b/src/sentry/workflow_engine/models/incident_groupopenperiod.py @@ -38,6 +38,9 @@ class IncidentGroupOpenPeriod(DefaultFieldsModel): class Meta: db_table = "workflow_engine_incidentgroupopenperiod" app_label = "workflow_engine" + indexes = [ + models.Index(fields=["incident_identifier"]), + ] constraints = [ models.CheckConstraint( condition=Q(incident_identifier__isnull=False) & Q(incident_id__isnull=False) From 634e93a9423550db9e2245cebf5c50c5fdff37fa Mon Sep 17 00:00:00 2001 From: Josh Callender <1569818+saponifi3d@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:51:40 -0800 Subject: [PATCH 2/2] Generated Migration --- migrations_lockfile.txt | 2 +- .../0105_add_incident_identifer_index.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/sentry/workflow_engine/migrations/0105_add_incident_identifer_index.py diff --git a/migrations_lockfile.txt b/migrations_lockfile.txt index 1fe6fd448dd8e2..3493ef5c884790 100644 --- a/migrations_lockfile.txt +++ b/migrations_lockfile.txt @@ -39,4 +39,4 @@ tempest: 0003_use_encrypted_char_field uptime: 0049_cleanup_failed_safe_deletes -workflow_engine: 0104_action_data_fallthrough_type +workflow_engine: 0105_add_incident_identifer_index diff --git a/src/sentry/workflow_engine/migrations/0105_add_incident_identifer_index.py b/src/sentry/workflow_engine/migrations/0105_add_incident_identifer_index.py new file mode 100644 index 00000000000000..e0120afb311d86 --- /dev/null +++ b/src/sentry/workflow_engine/migrations/0105_add_incident_identifer_index.py @@ -0,0 +1,35 @@ +# Generated by Django 5.2.8 on 2026-01-09 23:47 + +from django.db import migrations, models + +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", "1016_remove_on_command_phrase_trigger"), + ("workflow_engine", "0104_action_data_fallthrough_type"), + ] + + operations = [ + migrations.AddIndex( + model_name="incidentgroupopenperiod", + index=models.Index( + fields=["incident_identifier"], name="workflow_en_inciden_2450f4_idx" + ), + ), + ]