Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revertx4 "ref: replace deprecated index_together with indexes (#64055)" #64158

Merged
merged 2 commits into from
Jan 31, 2024
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
6 changes: 3 additions & 3 deletions migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ahead of you.
To resolve this, rebase against latest master and regenerate your migration. This file
will then be regenerated, and you should be able to merge without conflicts.

feedback: 0003_feedback_add_env
feedback: 0004_index_together
hybridcloud: 0009_make_user_id_optional_for_slug_reservation_replica
nodestore: 0002_nodestore_no_dictfield
replays: 0003_add_size_to_recording_segment
sentry: 0639_add_spec_version_to_dashboard_on_demand
replays: 0004_index_together
sentry: 0640_index_together
social_auth: 0002_default_auto_field
31 changes: 31 additions & 0 deletions src/sentry/feedback/migrations/0004_index_together.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.8 on 2024-01-31 10:04

from django.db import migrations

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. For
# the most part, 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 dangerous:
# - Large data migrations. Typically we want these to be run manually by ops 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
# have ops run this and not block the deploy. Note that while adding an index is a schema
# change, it's completely safe to run the operation after the code has deployed.
is_dangerous = False

dependencies = [
("feedback", "0003_feedback_add_env"),
]

operations = [
migrations.RenameIndex(
model_name="feedback",
new_name="feedback_fe_project_84fbf7_idx",
old_fields=("project_id", "date_added"),
),
]
2 changes: 1 addition & 1 deletion src/sentry/feedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class Feedback(Model):
class Meta:
app_label = "feedback"
db_table = "feedback_feedback"
index_together = [("project_id", "date_added")]
indexes = [models.Index(fields=("project_id", "date_added"))]

__repr__ = sane_repr("project_id", "feedback_id")
4 changes: 2 additions & 2 deletions src/sentry/incidents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Meta:
app_label = "sentry"
db_table = "sentry_incident"
unique_together = (("organization", "identifier"),)
index_together = (("alert_rule", "type", "status"),)
indexes = (models.Index(fields=("alert_rule", "type", "status")),)

@property
def current_end_date(self):
Expand Down Expand Up @@ -561,7 +561,7 @@ class Meta:
app_label = "sentry"
db_table = "sentry_incidenttrigger"
unique_together = (("incident", "alert_rule_trigger"),)
index_together = (("alert_rule_trigger", "incident_id"),)
indexes = (models.Index(fields=("alert_rule_trigger", "incident_id")),)


class AlertRuleTriggerManager(BaseManager["AlertRuleTrigger"]):
Expand Down
267 changes: 267 additions & 0 deletions src/sentry/migrations/0640_index_together.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
# Generated by Django 4.2.8 on 2024-01-31 10:04

from django.db import migrations

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. For
# the most part, 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 dangerous:
# - Large data migrations. Typically we want these to be run manually by ops 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
# have ops run this and not block the deploy. Note that while adding an index is a schema
# change, it's completely safe to run the operation after the code has deployed.
is_dangerous = False

dependencies = [
("sentry", "0639_add_spec_version_to_dashboard_on_demand"),
]

operations = [
migrations.RenameIndex(
model_name="activity",
new_name="sentry_acti_project_cd8457_idx",
old_fields=("project", "datetime"),
),
migrations.RenameIndex(
model_name="artifactbundleindex",
new_name="sentry_arti_url_7e628a_idx",
old_fields=("url", "artifact_bundle"),
),
migrations.RenameIndex(
model_name="commit",
new_name="sentry_comm_reposit_da31f2_idx",
old_fields=("repository_id", "date_added"),
),
migrations.RenameIndex(
model_name="commit",
new_name="sentry_comm_author__131211_idx",
old_fields=("author", "date_added"),
),
migrations.RenameIndex(
model_name="commit",
new_name="sentry_comm_organiz_7be514_idx",
old_fields=("organization_id", "date_added"),
),
migrations.RenameIndex(
model_name="controloutbox",
new_name="sentry_cont_region__0c4512_idx",
old_fields=("region_name", "shard_scope", "shard_identifier", "scheduled_for"),
),
migrations.RenameIndex(
model_name="controloutbox",
new_name="sentry_cont_region__a95d82_idx",
old_fields=("region_name", "shard_scope", "shard_identifier", "id"),
),
migrations.RenameIndex(
model_name="controloutbox",
new_name="sentry_cont_region__1c1c72_idx",
old_fields=(
"region_name",
"shard_scope",
"shard_identifier",
"category",
"object_identifier",
),
),
migrations.RenameIndex(
model_name="debugidartifactbundle",
new_name="sentry_debu_debug_i_8c6c44_idx",
old_fields=("debug_id", "artifact_bundle"),
),
migrations.RenameIndex(
model_name="eventattachment",
new_name="sentry_even_project_62b83b_idx",
old_fields=("project_id", "date_added"),
),
migrations.RenameIndex(
model_name="eventattachment",
new_name="sentry_even_project_974f7b_idx",
old_fields=("project_id", "event_id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_5eb75b_idx",
old_fields=("project", "status", "substatus", "last_seen", "id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_5acaf7_idx",
old_fields=("project", "status", "substatus", "id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_ff3fdf_idx",
old_fields=("project", "status", "substatus", "type", "last_seen", "id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_status_48b516_idx",
old_fields=("status", "substatus", "id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_status_e07f40_idx",
old_fields=("status", "substatus", "first_seen"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_4662d9_idx",
old_fields=("project", "first_release"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_81a5ed_idx",
old_fields=("project", "status", "last_seen", "id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_41a5ce_idx",
old_fields=("project", "id"),
),
migrations.RenameIndex(
model_name="group",
new_name="sentry_grou_project_17d28d_idx",
old_fields=("project", "status", "type", "last_seen", "id"),
),
migrations.RenameIndex(
model_name="groupenvironment",
new_name="sentry_grou_environ_443bdb_idx",
old_fields=("environment", "first_release", "first_seen"),
),
migrations.RenameIndex(
model_name="grouphistory",
new_name="sentry_grou_project_bbcf30_idx",
old_fields=("project", "status", "release"),
),
migrations.RenameIndex(
model_name="grouphistory",
new_name="sentry_grou_group_i_c61acb_idx",
old_fields=("group", "status"),
),
migrations.RenameIndex(
model_name="grouphistory",
new_name="sentry_grou_project_20b3f8_idx",
old_fields=("project", "date_added"),
),
migrations.RenameIndex(
model_name="groupinbox",
new_name="sentry_grou_project_a9fe16_idx",
old_fields=("project", "date_added"),
),
migrations.RenameIndex(
model_name="grouprelease",
new_name="sentry_grou_group_i_6eaff8_idx",
old_fields=("group_id", "first_seen"),
),
migrations.RenameIndex(
model_name="grouprelease",
new_name="sentry_grou_group_i_f10abe_idx",
old_fields=("group_id", "last_seen"),
),
migrations.RenameIndex(
model_name="incident",
new_name="sentry_inci_alert_r_24a457_idx",
old_fields=("alert_rule", "type", "status"),
),
migrations.RenameIndex(
model_name="incidenttrigger",
new_name="sentry_inci_alert_r_33da01_idx",
old_fields=("alert_rule_trigger", "incident_id"),
),
migrations.RenameIndex(
model_name="organizationmembermapping",
new_name="sentry_orga_organiz_ae9fe7_idx",
old_fields=("organization_id", "user"),
),
migrations.RenameIndex(
model_name="organizationmembermapping",
new_name="sentry_orga_organiz_7de26b_idx",
old_fields=("organization_id", "email"),
),
migrations.RenameIndex(
model_name="projectartifactbundle",
new_name="sentry_proj_project_f73d36_idx",
old_fields=("project_id", "artifact_bundle"),
),
migrations.RenameIndex(
model_name="projectdebugfile",
new_name="sentry_proj_project_c586ac_idx",
old_fields=("project_id", "debug_id"),
),
migrations.RenameIndex(
model_name="projectdebugfile",
new_name="sentry_proj_project_9b5950_idx",
old_fields=("project_id", "code_id"),
),
migrations.RenameIndex(
model_name="pullrequest",
new_name="sentry_pull_reposit_c429a4_idx",
old_fields=("repository_id", "date_added"),
),
migrations.RenameIndex(
model_name="pullrequest",
new_name="sentry_pull_organiz_8aabcf_idx",
old_fields=("organization_id", "merge_commit_sha"),
),
migrations.RenameIndex(
model_name="regionoutbox",
new_name="sentry_regi_shard_s_e7412f_idx",
old_fields=("shard_scope", "shard_identifier", "id"),
),
migrations.RenameIndex(
model_name="regionoutbox",
new_name="sentry_regi_shard_s_bfff84_idx",
old_fields=("shard_scope", "shard_identifier", "category", "object_identifier"),
),
migrations.RenameIndex(
model_name="regionoutbox",
new_name="sentry_regi_shard_s_cd9995_idx",
old_fields=("shard_scope", "shard_identifier", "scheduled_for"),
),
migrations.RenameIndex(
model_name="regressiongroup",
new_name="sentry_regr_type_3a29e7_idx",
old_fields=("type", "project_id", "fingerprint", "active"),
),
migrations.RenameIndex(
model_name="releaseartifactbundle",
new_name="sentry_rele_organiz_291018_idx",
old_fields=("organization_id", "release_name", "dist_name", "artifact_bundle"),
),
migrations.RenameIndex(
model_name="releasefile",
new_name="sentry_rele_release_bff97c_idx",
old_fields=("release_id", "name"),
),
migrations.RenameIndex(
model_name="releaseprojectenvironment",
new_name="sentry_rele_project_922a6a_idx",
old_fields=("project", "unadopted", "environment"),
),
migrations.RenameIndex(
model_name="releaseprojectenvironment",
new_name="sentry_rele_project_4bea8e_idx",
old_fields=("project", "adopted", "environment"),
),
migrations.RenameIndex(
model_name="rule",
new_name="sentry_rule_project_676d0d_idx",
old_fields=("project", "status", "owner"),
),
migrations.RenameIndex(
model_name="userreport",
new_name="sentry_user_project_b8faaf_idx",
old_fields=("project_id", "date_added"),
),
migrations.RenameIndex(
model_name="userreport",
new_name="sentry_user_project_cbfd59_idx",
old_fields=("project_id", "event_id"),
),
]
2 changes: 1 addition & 1 deletion src/sentry/models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Activity(Model):
class Meta:
app_label = "sentry"
db_table = "sentry_activity"
index_together = (("project", "datetime"),)
indexes = (models.Index(fields=("project", "datetime")),)

__repr__ = sane_repr("project_id", "group_id", "event_id", "user_id", "type", "ident")

Expand Down
12 changes: 8 additions & 4 deletions src/sentry/models/artifactbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class Meta:
app_label = "sentry"
db_table = "sentry_artifactbundleindex"

index_together = (("url", "artifact_bundle"),)
indexes = (models.Index(fields=("url", "artifact_bundle")),)


@region_silo_only_model
Expand All @@ -264,7 +264,11 @@ class Meta:

# We add the organization_id to this index since there are many occurrences of the same release/dist
# pair, and we would like to reduce the result set by scoping to the org.
index_together = (("organization_id", "release_name", "dist_name", "artifact_bundle"),)
indexes = (
models.Index(
fields=("organization_id", "release_name", "dist_name", "artifact_bundle")
),
)


@region_silo_only_model
Expand All @@ -281,7 +285,7 @@ class Meta:
app_label = "sentry"
db_table = "sentry_debugidartifactbundle"

index_together = (("debug_id", "artifact_bundle"),)
indexes = (models.Index(fields=("debug_id", "artifact_bundle")),)


@region_silo_only_model
Expand All @@ -297,7 +301,7 @@ class Meta:
app_label = "sentry"
db_table = "sentry_projectartifactbundle"

index_together = (("project_id", "artifact_bundle"),)
indexes = (models.Index(fields=("project_id", "artifact_bundle")),)


class ArtifactBundleArchive:
Expand Down
Loading
Loading