chore(alerts): Remove metric alert columns on NotificationMessage#115578
Conversation
wedamija
left a comment
There was a problem hiding this comment.
If these columns already have values, you can do the same thing that I did here:
https://github.com/getsentry/sentry/pull/115524/changes
However, it looks like there are many rows with null values: https://redash.de.getsentry.net/queries/367/source
So you either need to provide a default, or clean up these rows
|
This PR has a migration; here is the generated SQL for for --
-- Alter field action on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_action_id_e224a327_fk_workflow_" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_action_id_e224a327_fk_workflow_";
ALTER TABLE "sentry_notificationmessage" ALTER COLUMN "action_id" SET DEFAULT 0;
UPDATE "sentry_notificationmessage" SET "action_id" = 0 WHERE "action_id" IS NULL; SET CONSTRAINTS ALL IMMEDIATE;
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationm_action_id_e224a327_fk_workflow_" FOREIGN KEY ("action_id") REFERENCES "workflow_engine_action" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationm_action_id_e224a327_fk_workflow_";
--
-- Alter field group on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr";
ALTER TABLE "sentry_notificationmessage" ALTER COLUMN "group_id" SET DEFAULT 0;
UPDATE "sentry_notificationmessage" SET "group_id" = 0 WHERE "group_id" IS NULL; SET CONSTRAINTS ALL IMMEDIATE;
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr" FOREIGN KEY ("group_id") REFERENCES "sentry_groupedmessage" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr";
--
-- Alter field incident on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_incident_id_536f94b5_fk_sentry_in" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_incident_id_536f94b5_fk_sentry_in";
--
-- Alter field trigger_action on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_trigger_action_id_2f8dabba_fk_sentry_al" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_trigger_action_id_2f8dabba_fk_sentry_al";
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationmessage_action_id_e224a327_notnull" CHECK ("action_id" IS NOT NULL) NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationmessage_action_id_e224a327_notnull";
ALTER TABLE "sentry_notificationmessage" ALTER COLUMN "action_id" SET NOT NULL;
ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationmessage_action_id_e224a327_notnull";
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationmessage_group_id_6e588d2d_notnull" CHECK ("group_id" IS NOT NULL) NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationmessage_group_id_6e588d2d_notnull";
ALTER TABLE "sentry_notificationmessage" ALTER COLUMN "group_id" SET NOT NULL;
ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationmessage_group_id_6e588d2d_notnull"; |
eea68d7 to
814a8ef
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Alter field action on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_action_id_e224a327_fk_workflow_" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_action_id_e224a327_fk_workflow_";
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationm_action_id_e224a327_fk_workflow_" FOREIGN KEY ("action_id") REFERENCES "workflow_engine_action" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationm_action_id_e224a327_fk_workflow_";
--
-- Alter field group on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr";
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr" FOREIGN KEY ("group_id") REFERENCES "sentry_groupedmessage" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationm_group_id_6e588d2d_fk_sentry_gr";
--
-- Alter field incident on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_incident_id_536f94b5_fk_sentry_in" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_incident_id_536f94b5_fk_sentry_in";
--
-- Alter field trigger_action on notificationmessage
--
SET CONSTRAINTS "sentry_notificationm_trigger_action_id_2f8dabba_fk_sentry_al" IMMEDIATE; ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationm_trigger_action_id_2f8dabba_fk_sentry_al";
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationmessage_action_id_e224a327_notnull" CHECK ("action_id" IS NOT NULL) NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationmessage_action_id_e224a327_notnull";
ALTER TABLE "sentry_notificationmessage" ALTER COLUMN "action_id" SET NOT NULL;
ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationmessage_action_id_e224a327_notnull";
ALTER TABLE "sentry_notificationmessage" ADD CONSTRAINT "sentry_notificationmessage_group_id_6e588d2d_notnull" CHECK ("group_id" IS NOT NULL) NOT VALID;
ALTER TABLE "sentry_notificationmessage" VALIDATE CONSTRAINT "sentry_notificationmessage_group_id_6e588d2d_notnull";
ALTER TABLE "sentry_notificationmessage" ALTER COLUMN "group_id" SET NOT NULL;
ALTER TABLE "sentry_notificationmessage" DROP CONSTRAINT "sentry_notificationmessage_group_id_6e588d2d_notnull"; |
wedamija
left a comment
There was a problem hiding this comment.
I think that since this table is pretty huge we might need to set this as a post deploy migration. It doesn't add/remove any columns, just constraints so it should be fine.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 50ab3d0. Configure here.

Follow up to #115529 to start removing the
incidentandtrigger_actioncolumn onNotifcationMessage. Since onlyactionandgroupwill be used now, I'm trying to make those not nullable.Not to be merged until #115726 has been applied