-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add rule_entity_id
to rule_evaluations
#3999
Conversation
In order to replace the old evaluation status tables, we need to migrate any evaluation statuses to the new tables which predate the introduction of the new evaluation history tables. In order to simplify this migration, create a foreign key link from `rule_evaluations` to `evaluation_rule_entities` (the latter is essentially the new equivalent of the former). This PR also fixes some issues with the migration introduced in this previous PR.
|
||
-- First, add an ON DELETE CASCADE to the profile_id FK | ||
ALTER TABLE latest_evaluation_statuses DROP CONSTRAINT latest_evaluation_statuses_profile_id_fkey; | ||
ALTER TABLE latest_evaluation_statuses |
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.
@JAORMX I forgot to add an ON DELETE CASCADE
and I think that may have broke things
ON DELETE CASCADE; | ||
|
||
-- recreate index with default name | ||
DROP INDEX IF EXISTS idx_profile_id; |
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.
@blkt Fixed the index name issue here
@@ -129,71 +129,22 @@ func (e *executor) createOrUpdateEvalStatus( | |||
return nil | |||
} | |||
|
|||
// Upsert evaluation |
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.
These DB queries need to happen after the write to the evaluation history table since we are now tracking the rule-entity ID. They also now are run in the same transaction as the other queries.
In order to replace the old evaluation status tables, we need to migrate any evaluation statuses to the new tables which predate the introduction of the new evaluation history tables. In order to simplify this migration, create a foreign key link from
rule_evaluations
toevaluation_rule_entities
(the latter is essentially the new equivalent of the former). A foreign key reference torule_instances
is also added, this is also to simplify the migration.This PR also fixes some issues with the migration introduced in this previous PR.
Tested locally.
Summary
Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.
Fixes #(related issue)
Change Type
Mark the type of change your PR introduces:
Testing
Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.
Review Checklist: