Browse Source

feat(integrations): Add sentry_app_id column to sentry_alertruletriggeractions table (#20244)

Marcos Gaeta 4 years ago
parent
commit
97c8ab09cf

+ 1 - 1
migrations_lockfile.txt

@@ -10,7 +10,7 @@ auth: 0008_alter_user_username_max_length
 contenttypes: 0002_remove_content_type_name
 jira_ac: 0001_initial
 nodestore: 0001_initial
-sentry: 0096_sentry_app_component_skip_load_on_open
+sentry: 0097_add_sentry_app_id_to_sentry_alertruletriggeraction
 sessions: 0001_initial
 sites: 0002_alter_domain_unique
 social_auth: 0001_initial

+ 1 - 0
src/sentry/incidents/models.py

@@ -558,6 +558,7 @@ class AlertRuleTriggerAction(Model):
 
     alert_rule_trigger = FlexibleForeignKey("sentry.AlertRuleTrigger")
     integration = FlexibleForeignKey("sentry.Integration", null=True)
+    sentry_app = FlexibleForeignKey("sentry.SentryApp", null=True)
     type = models.SmallIntegerField()
     target_type = models.SmallIntegerField()
     # Identifier used to perform the action on a given target

+ 39 - 0
src/sentry/migrations/0097_add_sentry_app_id_to_sentry_alertruletriggeraction.py

@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.29 on 2020-08-14 20:18
+from __future__ import unicode_literals
+
+from django.db import migrations
+import django.db.models.deletion
+import sentry.db.models.fields.foreignkey
+
+
+class Migration(migrations.Migration):
+    # This flag is used to mark that a migration shouldn't be automatically run in
+    # production. We set this to True for operations that we think are risky and want
+    # someone from ops to run manually and monitor.
+    # General advice is that if in doubt, mark your migration as `is_dangerous`.
+    # Some things you should always mark as dangerous:
+    # - Large data migrations. Typically we want these to be run manually by ops so that
+    #   they can be monitored. Since data migrations will now hold a transaction open
+    #   this is even more important.
+    # - Adding columns to highly active tables, even ones that are NULL.
+    is_dangerous = False
+
+    # This flag is used to decide whether to run this migration in a transaction or not.
+    # By default we prefer to run in a transaction, but for migrations where you want
+    # to `CREATE INDEX CONCURRENTLY` this needs to be set to False. Typically you'll
+    # want to create an index concurrently when adding one to an existing table.
+    atomic = True
+
+
+    dependencies = [
+        ('sentry', '0096_sentry_app_component_skip_load_on_open'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='alertruletriggeraction',
+            name='sentry_app',
+            field=sentry.db.models.fields.foreignkey.FlexibleForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='sentry.SentryApp'),
+        ),
+    ]