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

ref(workflow_engine): Updates to the data models #80710

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

saponifi3d
Copy link
Contributor

Description

As we continue to spec out the migrations for issue alerts / metric alerts, we found a few more data model changes.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 13, 2024
Copy link

codecov bot commented Nov 13, 2024

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   #80710   +/-   ##
=======================================
  Coverage   78.42%   78.42%           
=======================================
  Files        7211     7212    +1     
  Lines      319719   319735   +16     
  Branches    44005    44005           
=======================================
+ Hits       250729   250748   +19     
+ Misses      62603    62601    -2     
+ Partials     6387     6386    -1     

Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Copy link
Contributor

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

--
-- Add field comparison_delta to detector
--
ALTER TABLE "workflow_engine_detector" ADD COLUMN "comparison_delta" integer NULL;
--
-- Add field description to detector
--
ALTER TABLE "workflow_engine_detector" ADD COLUMN "description" text NULL;
--
-- Custom state/database change combination
--

                    ALTER TABLE "workflow_engine_detector" ADD COLUMN "enabled" boolean NOT NULL DEFAULT true;
                    
--
-- Add field project to detector
--
ALTER TABLE "workflow_engine_detector" ADD COLUMN "project_id" bigint NULL;
--
-- Add field created_by to workflow
--
ALTER TABLE "workflow_engine_workflow" ADD COLUMN "created_by" bigint NULL;
--
-- Custom state/database change combination
--

                    ALTER TABLE "workflow_engine_workflow" ADD COLUMN "enabled" boolean NOT NULL DEFAULT true;
                    
--
-- Add field environment_id to workflow
--
ALTER TABLE "workflow_engine_workflow" ADD COLUMN "environment_id" integer NULL CHECK ("environment_id" >= 0);
--
-- Custom state/database change combination
--

                    ALTER TABLE "workflow_engine_workflow" ADD COLUMN "frequency" integer not null default 30;
                    
--
-- Add field owner_team to workflow
--
ALTER TABLE "workflow_engine_workflow" ADD COLUMN "owner_team_id" bigint NULL;
--
-- Add field owner_user_id to workflow
--
ALTER TABLE "workflow_engine_workflow" ADD COLUMN "owner_user_id" bigint NULL;
--
-- Alter field required on action
--
ALTER TABLE "workflow_engine_action" ALTER COLUMN "required" DROP NOT NULL;
--
-- Alter field organization on detector
--
SET CONSTRAINTS "workflow_engine_dete_organization_id_411c3ae7_fk_sentry_or" IMMEDIATE; ALTER TABLE "workflow_engine_detector" DROP CONSTRAINT "workflow_engine_dete_organization_id_411c3ae7_fk_sentry_or";
ALTER TABLE "workflow_engine_detector" ALTER COLUMN "organization_id" DROP NOT NULL;
ALTER TABLE "workflow_engine_detector" ADD CONSTRAINT "workflow_engine_dete_organization_id_411c3ae7_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_detector" VALIDATE CONSTRAINT "workflow_engine_dete_organization_id_411c3ae7_fk_sentry_or";
ALTER TABLE "workflow_engine_detector" ADD CONSTRAINT "workflow_engine_dete_project_id_275be9df_fk_sentry_pr" FOREIGN KEY ("project_id") REFERENCES "sentry_project" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_detector" VALIDATE CONSTRAINT "workflow_engine_dete_project_id_275be9df_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "workflow_engine_detector_project_id_275be9df" ON "workflow_engine_detector" ("project_id");
CREATE INDEX CONCURRENTLY "workflow_engine_workflow_created_by_a98158f7" ON "workflow_engine_workflow" ("created_by");
ALTER TABLE "workflow_engine_workflow" ADD CONSTRAINT "workflow_engine_work_owner_team_id_c401e7b8_fk_sentry_te" FOREIGN KEY ("owner_team_id") REFERENCES "sentry_team" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_workflow" VALIDATE CONSTRAINT "workflow_engine_work_owner_team_id_c401e7b8_fk_sentry_te";
CREATE INDEX CONCURRENTLY "workflow_engine_workflow_owner_team_id_c401e7b8" ON "workflow_engine_workflow" ("owner_team_id");
CREATE INDEX CONCURRENTLY "workflow_engine_workflow_owner_user_id_1ef7b270" ON "workflow_engine_workflow" ("owner_user_id");

@@ -21,17 +21,29 @@

@region_silo_model
class Detector(DefaultFieldsModel, OwnerModel):
__relocation_scope__ = RelocationScope.Organization
__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.

Why'd we move to excluded instead of project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't see a RelocationScope.Project - i was following the pattern i saw in other models that were related to the project.

can you link to an example and i'll follow that pattern? (thanks!)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think we're just meant to use Organization actually like

@region_silo_model
class ProjectOption(Model):
"""
Project options apply only to an instance of a project.
Options which are specific to a plugin should namespace
their key. e.g. key='myplugin:optname'
"""
__relocation_scope__ = RelocationScope.Organization

Copy link

codecov bot commented Nov 15, 2024

Bundle Report

Bundle size has no change ✅

saponifi3d and others added 21 commits November 15, 2024 16:35
…ject - removing the association with the organization since we can get that through the
- Add comparison_delta to the detector, this is used for comparison alerts.
- Add description for slack notifications
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 Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants