Skip to content

Commit 5a8daf3

Browse files
asottile-sentryandrewshie-sentry
authored andcommitted
ref: correct name of organization slug-upper index (#91896)
I accidentally represented this wrong in my state-only change #91879 -- uses another state-only change to correct that <!-- Describe your PR here. -->
1 parent f15b176 commit 5a8daf3

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ remote_subscriptions: 0003_drop_remote_subscription
2121

2222
replays: 0005_drop_replay_index
2323

24-
sentry: 0900_group_link_group_id_no_index
24+
sentry: 0901_org_slug_wrong_index_name
2525

2626
social_auth: 0002_default_auto_field
2727

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generated by Django 5.2.1 on 2025-05-19 18:16
2+
3+
import django.db.models.functions.text
4+
from django.db import migrations
5+
6+
import sentry.db.models.indexes
7+
from sentry.new_migrations.migrations import CheckedMigration
8+
9+
10+
class Migration(CheckedMigration):
11+
# This flag is used to mark that a migration shouldn't be automatically run in production.
12+
# This should only be used for operations where it's safe to run the migration after your
13+
# code has deployed. So this should not be used for most operations that alter the schema
14+
# of a table.
15+
# Here are some things that make sense to mark as post deployment:
16+
# - Large data migrations. Typically we want these to be run manually so that they can be
17+
# monitored and not block the deploy for a long period of time while they run.
18+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
19+
# run this outside deployments so that we don't block them. Note that while adding an index
20+
# is a schema change, it's completely safe to run the operation after the code has deployed.
21+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
22+
23+
is_post_deployment = False
24+
25+
dependencies = [
26+
("sentry", "0900_group_link_group_id_no_index"),
27+
]
28+
29+
operations = [
30+
migrations.SeparateDatabaseAndState(
31+
state_operations=[
32+
migrations.RemoveIndex(
33+
model_name="organization",
34+
name="organization_slug_upper_idx",
35+
),
36+
migrations.AddIndex(
37+
model_name="organization",
38+
index=sentry.db.models.indexes.IndexWithPostgresNameLimits(
39+
django.db.models.functions.text.Upper("slug"),
40+
name="sentry_organization_slug_upper_idx",
41+
),
42+
),
43+
]
44+
),
45+
]

src/sentry/models/organization.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
)
2525
from sentry.db.models import BoundedPositiveIntegerField, region_silo_model, sane_repr
2626
from sentry.db.models.fields.slug import SentryOrgSlugField
27+
from sentry.db.models.indexes import IndexWithPostgresNameLimits
2728
from sentry.db.models.manager.base import BaseManager
2829
from sentry.db.models.manager.base_query_set import BaseQuerySet
2930
from sentry.db.models.utils import slugify_instance
@@ -209,7 +210,9 @@ class flags(TypedClassBitField):
209210
class Meta:
210211
app_label = "sentry"
211212
db_table = "sentry_organization"
212-
indexes = (models.Index(Upper("slug"), name="organization_slug_upper_idx"),)
213+
indexes = (
214+
IndexWithPostgresNameLimits(Upper("slug"), name="sentry_organization_slug_upper_idx"),
215+
)
213216

214217
__repr__ = sane_repr("owner_id", "name", "slug")
215218

0 commit comments

Comments
 (0)