diff --git a/migrations_lockfile.txt b/migrations_lockfile.txt index 2d03a269bd5daf..9e9f6cb59f86fc 100644 --- a/migrations_lockfile.txt +++ b/migrations_lockfile.txt @@ -27,7 +27,7 @@ preprod: 0014_commitcomparisons_fk replays: 0006_add_bulk_delete_job -sentry: 0965_gzippeddict_big_tables +sentry: 0966_groupopenperiod_data_pending_inc_detector_id_index social_auth: 0003_social_auth_json_field diff --git a/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py b/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py new file mode 100644 index 00000000000000..1decad68a2d9cc --- /dev/null +++ b/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py @@ -0,0 +1,35 @@ +# Generated by Django 5.2.1 on 2025-08-08 23:06 + +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", "0965_gzippeddict_big_tables"), + ] + + operations = [ + migrations.AddIndex( + model_name="groupopenperiod", + index=models.Index( + models.F("data__pending_incident_detector_id"), + name="data__pend_inc_detector_id_idx", + ), + ), + ] diff --git a/src/sentry/models/groupopenperiod.py b/src/sentry/models/groupopenperiod.py index d5d7adef14cd1e..f3a89033183d6e 100644 --- a/src/sentry/models/groupopenperiod.py +++ b/src/sentry/models/groupopenperiod.py @@ -73,6 +73,10 @@ class Meta: indexes = ( # get all open periods since a certain date models.Index(fields=("group", "date_started")), + models.Index( + models.F("data__pending_incident_detector_id"), + name="data__pend_inc_detector_id_idx", + ), ) constraints = (