-
-
Notifications
You must be signed in to change notification settings - Fork 824
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] Mapping - Check FK on delete with SQL instead of PHP (dev/core#2757) #21198
Conversation
(Standard links)
|
@@ -1 +1,5 @@ | |||
{* file to handle db changes in 5.42.alpha1 during upgrade *} | |||
|
|||
ALTER TABLE `civicrm_mapping_field` DROP FOREIGN KEY `FK_civicrm_mapping_field_mapping_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.
@seamuslee001 I'm getting confused here - we use CRM_Core_BAO_SchemaHandler::safeRemoveFK(...)
to drop the fk I think but ?? to add one
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.
You could use this
civicrm-core/CRM/Core/BAO/SchemaHandler.php
Line 256 in 33f8687
public static function buildForeignKeySQL($params, $separator, $prefix, $tableName) { |
@eileenmcnaughton @seamuslee001 does this PR require a schema regen? |
@colemanw whilst you looking at mapping I'm wondering if we need to modify this https://github.com/civicrm/civicrm-core/blob/master/xml/schema/Contact/SavedSearch.xml#L82 at all |
@seamuslee001 why would we need to modify it? |
@colemanw should it be cascade delete also rather than set null? |
675b21d
to
92f44d4
Compare
@colemanw I've pushed up changes to the upgrade script as discussed above I tested locally upgrading from 5.42 to 5.43 with this version of the upgrade script I think @seamuslee001's question about search kit fk on mapping_id is out of scope - from memory it is used in search builder context and I have a feeling there might be some complications in answering the question about whether it should delete on cascade so it's not something we could 'quickly do while we are at it' This is mergeable now IMHO, Since I altered it I'm added 'merge-ready' not 'merge-on-pass' |
Thanks @eileenmcnaughton - this looks good except is this one of those situations where regen.sh has to be run and new sql install files committed? |
I don't think it does |
92f44d4
to
9f3b9e9
Compare
In that case this is good to go |
Overview
Part of an ongoing effort to clean up the DAO classes and use generic functions and events.
Before
For some reason, a php function was mimicking ON DELETE CASCADE in mySql.
After
Uses actual ON DELETE CASCADE in mySql.
Comments
The only reason I can fathom to do it in PHP rather than in SQL is to call pre and post hooks... which this wasn't.