-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
RelationshipCache - Add case_id column #21845
RelationshipCache - Add case_id column #21845
Conversation
This will hide that field when CiviCase is disabled
(Standard links)
|
4eb1d77
to
97b3849
Compare
I'm not sure what the tag does fully but I assume the above means "only present IN SEARCH KIT UI when CiviCase is enabled". Otherwise I ran the upgrade and clicked around a bit and it seems ok. I did notice a minor separate thing but I'll make a lab ticket. For the upgrade I started thinking about the fact that |
@demeritcowboy it means the column is only visible to APIv4 when the component is enabled. If tests are happy with it then I think it's a safe addition. |
public function upgrade_5_44_alpha1($rev) { | ||
// The runSql task populates the new column, so this addColumn task runs first | ||
$this->addTask('Add case_id column to civicrm_relationship_cache', 'addColumn', | ||
'civicrm_relationship_cache', 'case_id', "int unsigned DEFAULT NULL COMMENT 'FK to civicrm_case'" |
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.
@colemanw on upgrade your just adding the column not the FK but on install it would have an additional FK right based on the xml?
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.
Ugh, how do we even do that?
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.
if (!self::checkFKExists('civicrm_contribution_product', 'FK_civicrm_contribution_product_product_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.
Good catch @seamuslee001.
97b3849
to
bcd7e8d
Compare
Thanks @seamuslee001 and @demeritcowboy, I think I got the FK added correctly now. |
Thanks works ok for me.
I also checked that this doesn't prevent creating a regular relationship where case_id is null since I couldn't remember how that worked with foreign keys. And interestingly the |
Merge-on-pass? |
Overview
This makes it possible to show case relationships in SearchKit.
Before
Cannot filter relationships by case.
After
Can show relationships for specific cases.
Technical Details
This adds a mirror column to the relationship_cache table, since SearchKit can't do the complex joins that would be needed without the field present. SearchKit doesn't support the relationship table, it always uses RelationshipCache per #17781, therefore any data we need from relationships needs to be in the cache table.
While I was at it I also added the Component tag to the column in both tables, so it is only present when CiviCase is enabled.