Skip to content

Commit a806379

Browse files
authored
feat(hybridcloud): add index to apitokenreplica (#66947)
In support of: #65941 Adds an index for the `hashed_token` column on `ApiTokenReplica`.
1 parent ff3b313 commit a806379

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To resolve this, rebase against latest master and regenerate your migration. Thi
66
will then be regenerated, and you should be able to merge without conflicts.
77

88
feedback: 0004_index_together
9-
hybridcloud: 0014_apitokenreplica_add_hashed_token
9+
hybridcloud: 0015_apitokenreplica_hashed_token_index
1010
nodestore: 0002_nodestore_no_dictfield
1111
replays: 0004_index_together
1212
sentry: 0675_dashboard_widget_query_rename_priority_sort_to_trends
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 5.0.2 on 2024-03-14 10:40
2+
3+
from django.db import migrations, models
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
7+
8+
class Migration(CheckedMigration):
9+
# This flag is used to mark that a migration shouldn't be automatically run in production. For
10+
# the most part, this should only be used for operations where it's safe to run the migration
11+
# after your code has deployed. So this should not be used for most operations that alter the
12+
# schema of a table.
13+
# Here are some things that make sense to mark as dangerous:
14+
# - Large data migrations. Typically we want these to be run manually by ops so that they can
15+
# be monitored and not block the deploy for a long period of time while they run.
16+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
17+
# have ops run this and not block the deploy. Note that while adding an index is a schema
18+
# change, it's completely safe to run the operation after the code has deployed.
19+
is_dangerous = False
20+
21+
dependencies = [
22+
("hybridcloud", "0014_apitokenreplica_add_hashed_token"),
23+
("sentry", "0675_dashboard_widget_query_rename_priority_sort_to_trends"),
24+
]
25+
26+
operations = [
27+
migrations.AddIndex(
28+
model_name="apitokenreplica",
29+
index=models.Index(fields=["hashed_token"], name="hybridcloud_hashed__a93a8b_idx"),
30+
),
31+
]

src/sentry/hybridcloud/models/apitokenreplica.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ class ApiTokenReplica(Model, HasApiScopes):
2626
class Meta:
2727
app_label = "hybridcloud"
2828
db_table = "hybridcloud_apitokenreplica"
29-
indexes = (models.Index(fields=["token"]),)
29+
indexes = (
30+
models.Index(fields=["token"]),
31+
models.Index(fields=["hashed_token"]),
32+
)
3033

3134
__repr__ = sane_repr("user_id", "token", "application_id")
3235

0 commit comments

Comments
 (0)