I need to update the membership id and replace its value with that in the contact id's external identifier. So I followed the explaination here for CASCADE. https://stackoverflow.com/questions/31351819/how-do-i-add-on-update-cascade-to-my-existing-mysql-tables-through-phpmyadmin

Using that I changed properties to Cascade on Update under civicrm_membership_payment table which was earlier set to Restrict on Update

Now I went to the civicrm_membership table and updated a membership id whose value is present in civicrm_membership_payment,what that did was updated membership id value in two places 1) civicrm_membership 2) civicrm_membership_payment

So Cascading worked the query for the same was as seen below

ALTER TABLE `civicrm_membership_payment` 
DROP FOREIGN KEY `FK_civicrm_membership_payment_contribution_id`;
 ALTER TABLE `civicrm_membership_payment` 
ADD CONSTRAINT`FK_civicrm_membership_payment_contribution_id` 
FOREIGN KEY (`contribution_id`) 
REFERENCES `civicrm_contribution`(`id`) 
ALTER TABLE`civicrm_membership_payment` 
DROP FOREIGN KEY `FK_civicrm_membership_payment_membership_id`;
 ALTER TABLE `civicrm_membership_payment` 
ADD CONSTRAINT`FK_civicrm_membership_payment_membership_id`
 FOREIGN KEY (`membership_id`) REFERENCES `civicrm_membership`(`id`)

enter image description here To know the reason for auto increment you can refer
Now I need to auto increment membership id to a value 25000 as external
identifier start from 24999 and existing values are less than 24999
To do auto increment, I will follow the steps mentioned here


After AutoIncrement
I want to update membership ids for some of them with external identifiers (considering that its not possible to have a membership id which would be same as external identifiers as external identifiers all have ids greater than that of membership id in the civicrm_membership table.) that on all tables that would be affected when I update the id from civicrm_membership table. **What is the correct way to find out the list of tables which would be affected when we update civicrm_membership table's id? ** So that I can update relation properties and set it to Update on CASCADE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.