Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = False
Copy link
Member

Choose a reason for hiding this comment

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

This should be post-deployment migration, as this table has >260M rows, and adding index will probably time out if we do it as in-deploy migration.


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",
),
),
]
4 changes: 4 additions & 0 deletions src/sentry/models/groupopenperiod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Member Author

Choose a reason for hiding this comment

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

name is required and it's limited to 30 chars so I did the best I could here

),
)

constraints = (
Expand Down
Loading