|
| 1 | +# Generated by Django 2.2.28 on 2023-04-25 23:51 |
| 2 | + |
| 3 | +from django.db import migrations |
| 4 | + |
| 5 | +from sentry.new_migrations.migrations import CheckedMigration |
| 6 | + |
| 7 | + |
| 8 | +def fix_broken_external_issues(apps, schema_editor): |
| 9 | + ExternalIssue = apps.get_model("sentry", "ExternalIssue") |
| 10 | + |
| 11 | + # Broken issues from redash: https://redash.getsentry.net/queries/4012/source |
| 12 | + broken_ids = [636683, 636687, 636692] |
| 13 | + old_organization_id = 443715 |
| 14 | + new_organization_id = 5417824 |
| 15 | + for issue in ExternalIssue.objects.filter( |
| 16 | + id__in=broken_ids, organization_id=old_organization_id |
| 17 | + ): |
| 18 | + issue.organization_id = new_organization_id |
| 19 | + issue.save() |
| 20 | + |
| 21 | + |
| 22 | +class Migration(CheckedMigration): |
| 23 | + # This flag is used to mark that a migration shouldn't be automatically run in production. For |
| 24 | + # the most part, this should only be used for operations where it's safe to run the migration |
| 25 | + # after your code has deployed. So this should not be used for most operations that alter the |
| 26 | + # schema of a table. |
| 27 | + # Here are some things that make sense to mark as dangerous: |
| 28 | + # - Large data migrations. Typically we want these to be run manually by ops so that they can |
| 29 | + # be monitored and not block the deploy for a long period of time while they run. |
| 30 | + # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to |
| 31 | + # have ops run this and not block the deploy. Note that while adding an index is a schema |
| 32 | + # change, it's completely safe to run the operation after the code has deployed. |
| 33 | + is_dangerous = False |
| 34 | + |
| 35 | + dependencies = [ |
| 36 | + ("sentry", "0428_backfill_denormalize_notification_actor"), |
| 37 | + ] |
| 38 | + |
| 39 | + operations = [ |
| 40 | + migrations.RunPython( |
| 41 | + fix_broken_external_issues, |
| 42 | + reverse_code=migrations.RunPython.noop, |
| 43 | + hints={"tables": ["sentry_externalissue"]}, |
| 44 | + ), |
| 45 | + ] |
0 commit comments