-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
chore(aci): add WorkflowFireHistory model #88472
Conversation
This PR has a migration; here is the generated SQL for --
-- Create model WorkflowFireHistory
--
CREATE TABLE "workflow_engine_workflowfirehistory" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "event_id" text NOT NULL, "notification_uuid" uuid NOT NULL UNIQUE, "group_id" bigint NOT NULL, "workflow_id" bigint NOT NULL);
ALTER TABLE "workflow_engine_workflowfirehistory" ADD CONSTRAINT "workflow_engine_work_group_id_d0001482_fk_sentry_gr" FOREIGN KEY ("group_id") REFERENCES "sentry_groupedmessage" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_workflowfirehistory" VALIDATE CONSTRAINT "workflow_engine_work_group_id_d0001482_fk_sentry_gr";
ALTER TABLE "workflow_engine_workflowfirehistory" ADD CONSTRAINT "workflow_engine_work_workflow_id_7c271053_fk_workflow_" FOREIGN KEY ("workflow_id") REFERENCES "workflow_engine_workflow" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_workflowfirehistory" VALIDATE CONSTRAINT "workflow_engine_work_workflow_id_7c271053_fk_workflow_";
CREATE INDEX CONCURRENTLY "workflow_engine_workflowfirehistory_group_id_d0001482" ON "workflow_engine_workflowfirehistory" ("group_id");
CREATE INDEX CONCURRENTLY "workflow_engine_workflowfirehistory_workflow_id_7c271053" ON "workflow_engine_workflowfirehistory" ("workflow_id"); |
workflow = FlexibleForeignKey("workflow_engine.Workflow", db_constraint=False) | ||
group = FlexibleForeignKey("sentry.Group", db_constraint=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why db_constraint=False
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk i copied what you did here, i should probably at least add the constraint back to workflow
sentry/src/sentry/models/rulefirehistory.py
Lines 13 to 15 in 22e6926
project = FlexibleForeignKey("sentry.Project", db_constraint=False) | |
rule = FlexibleForeignKey("sentry.Rule") | |
group = FlexibleForeignKey("sentry.Group", db_constraint=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like DB constraint is false in case the group is deleted, we still want to have a record of when the rule fired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time it was risky to add relations to busy tables like Project
and Group
, since we didn't have our migration safety framework in place. It's not a problem anymore, so you're better off putting these constraints in.
Setting db_constraint=False
doesn't prevent cascade deletions, all it does it remove the db level fk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added it back in, i think cascade deletions is fine
|
||
|
||
@region_silo_model | ||
class WorkflowFireHistory(DefaultFieldsModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need notification_uuid
like in the previous table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure what it's used for, need to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added it back in
workflow = FlexibleForeignKey("workflow_engine.Workflow") | ||
group = FlexibleForeignKey("sentry.Group") | ||
event_id = CharField(max_length=32) | ||
notification_uuid = UUIDField(auto_add=True, unique=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know how this col is used, but I just want to check that it's valid to always have a notification uuid here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently no rows in RuleFireHistory have a null notification_uuid
so it's ok to require
We need a
WorkflowFireHistory
model to support the workflow engine equivalent of the fire history graph and table that currently exists for issue alerts