|
| 1 | +# Generated by Django 5.2.1 on 2025-07-09 17:43 |
| 2 | + |
| 3 | +import django.db.models.deletion |
| 4 | +from django.db import migrations, models |
| 5 | + |
| 6 | +import sentry.db.models.fields.bounded |
| 7 | +import sentry.db.models.fields.foreignkey |
| 8 | +from sentry.new_migrations.migrations import CheckedMigration |
| 9 | +from sentry.new_migrations.monkey.special import SafeRunSQL |
| 10 | + |
| 11 | + |
| 12 | +class Migration(CheckedMigration): |
| 13 | + # This flag is used to mark that a migration shouldn't be automatically run in production. |
| 14 | + # This should only be used for operations where it's safe to run the migration after your |
| 15 | + # code has deployed. So this should not be used for most operations that alter the schema |
| 16 | + # of a table. |
| 17 | + # Here are some things that make sense to mark as post deployment: |
| 18 | + # - Large data migrations. Typically we want these to be run manually so that they can be |
| 19 | + # monitored and not block the deploy for a long period of time while they run. |
| 20 | + # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to |
| 21 | + # run this outside deployments so that we don't block them. Note that while adding an index |
| 22 | + # is a schema change, it's completely safe to run the operation after the code has deployed. |
| 23 | + # Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment |
| 24 | + |
| 25 | + is_post_deployment = False |
| 26 | + |
| 27 | + dependencies = [ |
| 28 | + ("sentry", "0943_create_data_access_grant"), |
| 29 | + ("workflow_engine", "0075_add_index_to_dcg_action"), |
| 30 | + ] |
| 31 | + |
| 32 | + operations = [ |
| 33 | + SafeRunSQL( |
| 34 | + """DROP TABLE IF EXISTS "workflow_engine_detectorgroup";""", |
| 35 | + reverse_sql=migrations.RunSQL.noop, |
| 36 | + hints={"tables": ["workflow_engine_detectorgroup"]}, |
| 37 | + ), # this migration was successfully run in S4S and DE, failed in US |
| 38 | + migrations.CreateModel( |
| 39 | + name="DetectorGroup", |
| 40 | + fields=[ |
| 41 | + ( |
| 42 | + "id", |
| 43 | + sentry.db.models.fields.bounded.BoundedBigAutoField( |
| 44 | + primary_key=True, serialize=False |
| 45 | + ), |
| 46 | + ), |
| 47 | + ("date_updated", models.DateTimeField(auto_now=True)), |
| 48 | + ("date_added", models.DateTimeField(auto_now_add=True)), |
| 49 | + ( |
| 50 | + "detector", |
| 51 | + sentry.db.models.fields.foreignkey.FlexibleForeignKey( |
| 52 | + on_delete=django.db.models.deletion.CASCADE, |
| 53 | + to="workflow_engine.detector", |
| 54 | + ), |
| 55 | + ), |
| 56 | + ( |
| 57 | + "group", |
| 58 | + sentry.db.models.fields.foreignkey.FlexibleForeignKey( |
| 59 | + db_constraint=False, |
| 60 | + on_delete=django.db.models.deletion.CASCADE, |
| 61 | + to="sentry.group", |
| 62 | + ), |
| 63 | + ), |
| 64 | + ], |
| 65 | + options={ |
| 66 | + "db_table": "workflow_engine_detectorgroup", |
| 67 | + }, |
| 68 | + ), |
| 69 | + ] |
0 commit comments