Skip to content

Commit f243492

Browse files
authored
ref(saved search): Migrate betterPriority to priority (#52909)
Now that we've GA'd the new priority sort, we should clean up the saved searches that were made with the sort "betterPriority". Step 1: Front end PR to stop saving searches w/ betterPriority #52910 Step 2: This PR Step 3: Backend PR #52915
1 parent 316f77a commit f243492

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

migrations_lockfile.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ 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
nodestore: 0002_nodestore_no_dictfield
9-
sentry: 0513_django_jsonfield
9+
sentry: 0514_migrate_priority_saved_searches
1010
social_auth: 0001_initial
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Generated by Django 3.2.20 on 2023-07-14 19:44
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
from sentry.utils.query import RangeQuerySetWrapperWithProgressBar
7+
8+
9+
def migrate_saved_searches(apps, schema_editor):
10+
SavedSearch = apps.get_model("sentry", "SavedSearch")
11+
for search in RangeQuerySetWrapperWithProgressBar(SavedSearch.objects.all()):
12+
if search.sort == "betterPriority":
13+
search.sort = "priority"
14+
search.save()
15+
16+
17+
class Migration(CheckedMigration):
18+
# This flag is used to mark that a migration shouldn't be automatically run in production. For
19+
# the most part, this should only be used for operations where it's safe to run the migration
20+
# after your code has deployed. So this should not be used for most operations that alter the
21+
# schema of a table.
22+
# Here are some things that make sense to mark as dangerous:
23+
# - Large data migrations. Typically we want these to be run manually by ops so that they can
24+
# be monitored and not block the deploy for a long period of time while they run.
25+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
26+
# have ops run this and not block the deploy. Note that while adding an index is a schema
27+
# change, it's completely safe to run the operation after the code has deployed.
28+
is_dangerous = False
29+
30+
dependencies = [
31+
("sentry", "0513_django_jsonfield"),
32+
]
33+
34+
operations = [
35+
migrations.RunPython(
36+
migrate_saved_searches,
37+
migrations.RunPython.noop,
38+
hints={"tables": ["sentry_savedsearch"]},
39+
),
40+
]

0 commit comments

Comments
 (0)