Skip to content
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

feat(ACI): Add IncidentGroupOpenPeriod lookup table #88856

Merged
merged 7 commits into from
Apr 8, 2025

Conversation

ceorourke
Copy link
Member

Add another lookup table between incidents and groupopenperiods to support the old endpoints without having to rely on the old models. More context in https://www.notion.so/sentry/Old-Endpoints-New-Models-1bd8b10e4b5d803d80a9d9d05b6b88b4?pvs=4#1c38b10e4b5d80ab8bb4cba4b55503c2

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 4, 2025
Copy link
Contributor

github-actions bot commented Apr 4, 2025

This PR has a migration; here is the generated SQL for src/sentry/workflow_engine/migrations/0043_create_incidentgroupopenperiod_lookup_table.py ()

--
-- Create model IncidentGroupOpenPeriod
--
CREATE TABLE "workflow_engine_incidentgroupopenperiod" ("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, "incident_id" bigint NULL UNIQUE, "group_open_period_id" bigint NOT NULL UNIQUE);
ALTER TABLE "workflow_engine_incidentgroupopenperiod" ADD CONSTRAINT "workflow_engine_inci_group_open_period_id_b5c3857c_fk_sentry_gr" FOREIGN KEY ("group_open_period_id") REFERENCES "sentry_groupopenperiod" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_incidentgroupopenperiod" VALIDATE CONSTRAINT "workflow_engine_inci_group_open_period_id_b5c3857c_fk_sentry_gr";

Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #88856       +/-   ##
===========================================
+ Coverage   32.97%   87.74%   +54.76%     
===========================================
  Files        8512    10080     +1568     
  Lines      475426   570753    +95327     
  Branches    22372    22372               
===========================================
+ Hits       156780   500808   +344028     
+ Misses     318247    69546   -248701     
  Partials      399      399               

@ceorourke ceorourke marked this pull request as ready for review April 4, 2025 22:20
@ceorourke ceorourke requested review from a team as code owners April 4, 2025 22:20
Copy link
Contributor

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

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

lgtm - do you need a migration owners +1 too?

Comment on lines 28 to 31
UniqueConstraint(
fields=["incident_id", "group_open_period"],
name="workflow_engine_uniq_incident_groupopenperiod",
)
Copy link
Member

Choose a reason for hiding this comment

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

What unique constraint do we want here? Should there only ever be one incident id in the table, and one group open period in the table?

We need either both the uniques on the columns, or this unique, depending on what you need here

Copy link
Member Author

Choose a reason for hiding this comment

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

Should there only ever be one incident id in the table, and one group open period in the table?

Yes to this ^ should I remove the UniqueConstraint?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, removed the combined constraint, it's not necessary

Copy link
Member Author

Choose a reason for hiding this comment

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

ok updated 👍


__relocation_scope__ = RelocationScope.Excluded

incident_id = BoundedBigIntegerField(null=True, unique=True)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be nullable? I guess it's null for incidents created after we stop writing to Incident?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah nullable just in case we need to fudge the id

@ceorourke ceorourke requested a review from wedamija April 8, 2025 21:21
@ceorourke ceorourke merged commit 64f04ee into master Apr 8, 2025
60 checks passed
@ceorourke ceorourke deleted the ceorourke/ACI-224 branch April 8, 2025 22:07
Christinarlong pushed a commit that referenced this pull request Apr 10, 2025
Add another lookup table between incidents and groupopenperiods to
support the old endpoints without having to rely on the old models. More
context in
https://www.notion.so/sentry/Old-Endpoints-New-Models-1bd8b10e4b5d803d80a9d9d05b6b88b4?pvs=4#1c38b10e4b5d80ab8bb4cba4b55503c2
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.

5 participants