Skip to content

feat(aci): add WorkflowActionGroupStatus table #91993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ tempest: 0001_squashed_0002_make_message_type_nullable

uptime: 0001_squashed_0042_extra_uptime_indexes

workflow_engine: 0001_squashed_0065_add_status_to_detector_and_workflow
workflow_engine: 0066_workflow_action_group_status_table
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Generated by Django 5.2.1 on 2025-05-21 20:30

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", "0905_fix_workflow_engine_cycle"),
("workflow_engine", "0001_squashed_0065_add_status_to_detector_and_workflow"),
]

operations = [
migrations.CreateModel(
name="WorkflowActionGroupStatus",
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"
),
),
(
"group",
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="sentry.group"
),
),
(
"workflow",
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="workflow_engine.workflow"
),
),
],
options={
"constraints": [
models.UniqueConstraint(
fields=("workflow", "action", "group"),
name="workflow_engine_uniq_workflow_action_group",
)
],
},
),
]
2 changes: 2 additions & 0 deletions src/sentry/workflow_engine/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"Workflow",
"WorkflowDataConditionGroup",
"WorkflowFireHistory",
"WorkflowActionGroupStatus",
]

from .action import Action
Expand All @@ -37,5 +38,6 @@
from .detector_workflow import DetectorWorkflow
from .incident_groupopenperiod import IncidentGroupOpenPeriod
from .workflow import Workflow
from .workflow_action_group_status import WorkflowActionGroupStatus
from .workflow_data_condition_group import WorkflowDataConditionGroup
from .workflow_fire_history import WorkflowFireHistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db import models

from sentry.backup.scopes import RelocationScope
from sentry.db.models import DefaultFieldsModel, FlexibleForeignKey, region_silo_model


@region_silo_model
class WorkflowActionGroupStatus(DefaultFieldsModel):
"""
Stores when a workflow action last fired for a Group.
"""

__relocation_scope__ = RelocationScope.Excluded
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an account is relocated, do we not want the history of their alert workflows to be preserved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this is the workflow engine equivalent to GroupRuleStatus which is excluded from relocation. i'm not entirely sure why, though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is much too much data to relocate, we usually exclude things that are related to groups


workflow = FlexibleForeignKey("workflow_engine.Workflow", on_delete=models.CASCADE)
action = FlexibleForeignKey("workflow_engine.Action", on_delete=models.CASCADE)
group = FlexibleForeignKey("sentry.Group")

class Meta:
constraints = [
models.UniqueConstraint(
fields=["workflow", "action", "group"],
name="workflow_engine_uniq_workflow_action_group",
)
]
Loading