|
| 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