-
-
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
feat(ACI): Break lookup table foreign keys #88407
Conversation
This PR has a migration; here is the generated SQL for --
-- Custom state/database change combination
--
SET CONSTRAINTS "workflow_engine_acti_alert_rule_trigger_a_a7580a99_fk_sentry_al" IMMEDIATE; ALTER TABLE "workflow_engine_actionalertruletriggeraction" DROP CONSTRAINT "workflow_engine_acti_alert_rule_trigger_a_a7580a99_fk_sentry_al";
SET CONSTRAINTS "workflow_engine_aler_alert_rule_id_c81b0f4b_fk_sentry_al" IMMEDIATE; ALTER TABLE "workflow_engine_alertruledetector" DROP CONSTRAINT "workflow_engine_aler_alert_rule_id_c81b0f4b_fk_sentry_al";
SET CONSTRAINTS "workflow_engine_aler_rule_id_26bc9c69_fk_sentry_ru" IMMEDIATE; ALTER TABLE "workflow_engine_alertruledetector" DROP CONSTRAINT "workflow_engine_aler_rule_id_26bc9c69_fk_sentry_ru";
SET CONSTRAINTS "workflow_engine_aler_alert_rule_id_952ceb2c_fk_sentry_al" IMMEDIATE; ALTER TABLE "workflow_engine_alertruleworkflow" DROP CONSTRAINT "workflow_engine_aler_alert_rule_id_952ceb2c_fk_sentry_al";
SET CONSTRAINTS "workflow_engine_aler_rule_id_c93d1444_fk_sentry_ru" IMMEDIATE; ALTER TABLE "workflow_engine_alertruleworkflow" DROP CONSTRAINT "workflow_engine_aler_rule_id_c93d1444_fk_sentry_ru"; |
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #88407 +/- ##
========================================
Coverage 87.75% 87.75%
========================================
Files 10021 10028 +7
Lines 567728 567933 +205
Branches 22296 22296
========================================
+ Hits 498183 498378 +195
- Misses 69125 69135 +10
Partials 420 420 |
Need to rebase after #88407 is merged |
d76157a
to
b996030
Compare
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.
Mostly lgtm. One other thing to think about is that now that we've broken these fks, then if we deleted the rows on the other side of the key we won't automatically delete these rows, and so they'll be orphaned.
You probably need to add things to deletions so that these models know how to delete these dangling rows. Here's an example:
relations.append(ModelRelation(Monitor, {"project_id": instance.id})) |
src/sentry/workflow_engine/models/action_alertruletriggeraction.py
Outdated
Show resolved
Hide resolved
Yes, you'll need to update deletions and add the relations explicitly as django won't handle the deletion cascade anymore. |
89eb21f
to
4523cc8
Compare
Looks good, but you'll need to go through uses in |
Oh yeah I have updated all those, just need to do one more rebase. |
c28f4f9
to
fb557f6
Compare
This PR has a migration; here is the generated SQL for --
-- Custom state/database change combination
--
SET CONSTRAINTS "workflow_engine_acti_alert_rule_trigger_a_a7580a99_fk_sentry_al" IMMEDIATE; ALTER TABLE "workflow_engine_actionalertruletriggeraction" DROP CONSTRAINT "workflow_engine_acti_alert_rule_trigger_a_a7580a99_fk_sentry_al";
SET CONSTRAINTS "workflow_engine_aler_alert_rule_id_c81b0f4b_fk_sentry_al" IMMEDIATE; ALTER TABLE "workflow_engine_alertruledetector" DROP CONSTRAINT "workflow_engine_aler_alert_rule_id_c81b0f4b_fk_sentry_al";
SET CONSTRAINTS "workflow_engine_aler_rule_id_26bc9c69_fk_sentry_ru" IMMEDIATE; ALTER TABLE "workflow_engine_alertruledetector" DROP CONSTRAINT "workflow_engine_aler_rule_id_26bc9c69_fk_sentry_ru";
SET CONSTRAINTS "workflow_engine_aler_alert_rule_id_952ceb2c_fk_sentry_al" IMMEDIATE; ALTER TABLE "workflow_engine_alertruleworkflow" DROP CONSTRAINT "workflow_engine_aler_alert_rule_id_952ceb2c_fk_sentry_al";
SET CONSTRAINTS "workflow_engine_aler_rule_id_c93d1444_fk_sentry_ru" IMMEDIATE; ALTER TABLE "workflow_engine_alertruleworkflow" DROP CONSTRAINT "workflow_engine_aler_rule_id_c93d1444_fk_sentry_ru"; |
@wedamija ok all up to date now |
Change the lookup tables' foreign keys to store IDs and rename so it reflects what it holds now. See https://www.notion.so/sentry/Old-Endpoints-New-Models-1bd8b10e4b5d803d80a9d9d05b6b88b4?pvs=4#1c28b10e4b5d80c5a254dbb442f6859d for a lot more context on this change, but the tl;dr is we don't want to have to rely on old models that we will be deleting for IDs we only need for a short period of time.
Change the lookup tables' foreign keys to store IDs and rename so it reflects what it holds now.
See https://www.notion.so/sentry/Old-Endpoints-New-Models-1bd8b10e4b5d803d80a9d9d05b6b88b4?pvs=4#1c28b10e4b5d80c5a254dbb442f6859d for a lot more context on this change, but the tl;dr is we don't want to have to rely on old models that we will be deleting for IDs we only need for a short period of time.