-
Notifications
You must be signed in to change notification settings - Fork 37
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 project_id column to rule_instances #3570
Conversation
This provides a more elegant solution to the `ON CASCADE DELETE` problem.
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.
Overall, I like this simplification. Maybe we're okay at the moment with causing minder failures during rollout due to adding NOT NULL columns to the schema, but I wanted to check.
If you want to split it up, I would add the column with no constraints and the new queries, and then do a second migration PR that does the backfill and adds the constraint.
WHERE ri.profile_id = pf.id; | ||
|
||
-- now we can add the not null constraint | ||
ALTER TABLE rule_instances ALTER COLUMN project_id SET NOT NULL; |
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.
Won't this cause current-minder to fail after the DB migration until the new deployment occurs?
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.
Good point, will remove this.
BEGIN; | ||
|
||
-- add column, leave as not null until we populate the column | ||
ALTER TABLE rule_instances ADD COLUMN project_id UUID REFERENCES projects(id) ON DELETE CASCADE; |
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 want or need an index on project_id 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.
At this point in time, we don't use the new column in the queries since the tuple of (name, profile_id, entity_type) is still unique. As I add more queries, I will add more indices based on common query patterns.
e10f877
to
136703e
Compare
136703e
to
62d6507
Compare
This provides a more elegant solution to the
ON CASCADE DELETE
problem with therule_instance
table. 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: