Skip to content

Commit

Permalink
create lookup table for legacy actions to new actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mifu67 committed Jan 14, 2025
1 parent 699ee6c commit 4488598
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ tempest: 0001_create_tempest_credentials_model

uptime: 0021_drop_region_table_col

workflow_engine: 0022_add_action_group_status_model
workflow_engine: 0023_create_action_trigger_action_table
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 5.1.4 on 2025-01-14 21:18

import django.db.models.deletion
from django.db import migrations, models

import sentry.db.models.fields.bounded
import sentry.db.models.fields.foreignkey
from sentry.new_migrations.migrations import CheckedMigration


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# This should only be used for operations where it's safe to run the migration after your
# code has deployed. So this should not be used for most operations that alter the schema
# of a table.
# Here are some things that make sense to mark as post deployment:
# - Large data migrations. Typically we want these to be run manually so that they can be
# monitored and not block the deploy for a long period of time while they run.
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

dependencies = [
("sentry", "0813_rm_alertruleactivation_models"),
("workflow_engine", "0022_add_action_group_status_model"),
]

operations = [
migrations.CreateModel(
name="ActionAlertRuleTriggerAction",
fields=[
(
"id",
sentry.db.models.fields.bounded.BoundedBigAutoField(
primary_key=True, serialize=False
),
),
("date_updated", models.DateTimeField(auto_now=True)),
("date_added", models.DateTimeField(auto_now_add=True)),
(
"action",
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="workflow_engine.action"
),
),
(
"alert_rule_trigger_action",
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="sentry.alertruletriggeraction",
),
),
],
options={
"abstract": False,
},
),
]
2 changes: 2 additions & 0 deletions src/sentry/workflow_engine/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = [
"Action",
"ActionAlertRuleTriggerAction",
"ActionGroupStatus",
"AlertRuleDetector",
"AlertRuleTriggerDataCondition",
Expand All @@ -18,6 +19,7 @@
]

from .action import Action
from .action_alertruletriggeraction import ActionAlertRuleTriggerAction
from .action_group_status import ActionGroupStatus
from .alertrule_detector import AlertRuleDetector
from .alertrule_workflow import AlertRuleWorkflow
Expand Down
14 changes: 14 additions & 0 deletions src/sentry/workflow_engine/models/action_alertruletriggeraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sentry.backup.scopes import RelocationScope
from sentry.db.models import DefaultFieldsModel, FlexibleForeignKey, region_silo_model


@region_silo_model
class ActionAlertRuleTriggerAction(DefaultFieldsModel):
"""
A lookup model for Actions (new) and AlertRuleTriggerActions (legacy)
"""

__relocation_scope__ = RelocationScope.Organization

action = FlexibleForeignKey("workflow_engine.Action")
alert_rule_trigger_action = FlexibleForeignKey("sentry.AlertRuleTriggerAction")

0 comments on commit 4488598

Please sign in to comment.