Skip to content

chore(alerts): Remove metric alert constraint on NotificationMessage#115529

Open
ceorourke wants to merge 3 commits into
masterfrom
ceorourke/rm-metric-alert-constraints-notifmsg
Open

chore(alerts): Remove metric alert constraint on NotificationMessage#115529
ceorourke wants to merge 3 commits into
masterfrom
ceorourke/rm-metric-alert-constraints-notifmsg

Conversation

@ceorourke
Copy link
Copy Markdown
Member

Now that we've cleaned up usage we are no longer using the metric alert columns on this model and are exclusively writing to action and group for workflow engine notifications. Remove the constraints for metric alert notification messages so that we can remove the incident and trigger_action columns in follow ups. This is slightly risky in that technically without the constraint someone could write incorrect fields, but I'll be doing these migrations one after the other so the risk is minimal. I am planning to make action and group both not nullable.

@ceorourke ceorourke requested review from a team as code owners May 13, 2026 22:54
@ceorourke ceorourke changed the title chore(alerts): Remove metric alert constraint on notificationmessage chore(alerts): Remove metric alert constraint on NotificationMessage May 13, 2026
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/notifications/migrations/0008_remove_metric_alert_constraints_notificationmessage.py

for 0008_remove_metric_alert_constraints_notificationmessage in notifications

--
-- Remove constraint singular_parent_message_per_incident_and_trigger_action from model notificationmessage
--
DROP INDEX CONCURRENTLY IF EXISTS "singular_parent_message_per_incident_and_trigger_action";
--
-- Remove constraint notifmsg_metric_or_workflow_exclusive from model notificationmessage
--
ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "notifmsg_metric_or_workflow_exclusive";

@ceorourke ceorourke requested a review from a team as a code owner May 13, 2026 23:11
@ceorourke ceorourke requested a review from a team as a code owner May 13, 2026 23:13
name="idx_notifmsg_group_action_date",
),
]
constraints = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need some of these constraints? Or are they all unused now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll be removing incident and trigger action so the only constraint we might want is that both action and group are set but I intend to enforce that by removing the nullability on them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants