Answers.Body: <p>You can also use the API with <code>cv</code>, <code>drush</code>, or <code>wp-cli</code> to call <code>System.flush</code> with the parameter <code>triggers=TRUE</code>. E.g. <code>cv api System.flush triggers=TRUE</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-01T23:03:06.117Z
Answers.LastActivityDate: 2023-02-01T23:03:06.117Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I am getting this error " [nativecode=1442 ** Can't update table 'civicrm_contact' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.]" after both migrating my database to another server and upgrading to the 5.19 security upgrade.  </p>
  
  <p>I have attempted multiple times to run the trigger rebuild URL for Drupal and to use 
  <code>cv php:eval "CRM_Core_DAO::dropTriggers('civicrm_contact');"
   cv php:eval "CRM_Core_DAO::triggerRebuild('civicrm_contact');"
  cv php:eval "CRM_Core_DAO::dropTriggers('civicrm_contribution');"
   cv php:eval "CRM_Core_DAO::triggerRebuild('civicrm_contribution');"
  </code>
  Any ideas of what else to try I would appreciate it. </p>
  
  <p>Thanks,
  Josh</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-26T10:53:19.297Z
Comments.Text: Have you tried the standard trigger rebuild? https://example.com/civicrm/menu/rebuild?reset=1&triggerRebuild=1
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-26T15:06:39.353Z
Comments.Text: Yes, I started with that a couple of times before pulling out any code.  Thanks!
Comments.UserDisplayName: Josh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-28T05:40:10.357Z
Comments.Text: Is there any information about what trigger is causing this error? Do you have logging enabled (civicrm/admin/setting/misc?reset=1)  What do you get when you run the following sql query? "show triggers like 'civicrm_contact%';"
Comments.UserDisplayName: Luke Stewart
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-28T06:08:36.607Z
Comments.Text: @Luke Strwart, I do not have logging enabled.  When I do the query you gave me I get one on insert query that is too long to post here. I tried running the drop triggers again to see if it goes away and it does not. Can I safely drop it? Thanks! Happy Thanksgiving!
Comments.UserDisplayName: Josh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-28T18:02:57.380Z
Comments.Text: Assuming no customisations are involved it's totally fine to manually delete the trigger then run rebuild triggers via the drupal rebuild. 
  
  What is the trigger of the error - can you replicate it? What is the calling function?
Comments.UserDisplayName: Luke Stewart
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-01T01:55:03.840Z
Comments.Text: The thing I got to work in the end was to delete the two triggers that were there for on create and on update and then install 5.19.3.
Comments.UserDisplayName: Josh
Tags: <civicontribute><database>
Title: Trigger Rebuild Is Not Working
ThreadText: # Trigger Rebuild Is Not Working
  
  (Asked by: username_0 on 2019-11-26)
  
  I am getting this error " [nativecode=1442 \*\* Can't update table 'civicrm\_contact' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.]" after both migrating my database to another server and upgrading to the 5.19 security upgrade.
  
  I have attempted multiple times to run the trigger rebuild URL for Drupal and to use
  `cv php:eval "CRM_Core_DAO::dropTriggers('civicrm_contact');"
  cv php:eval "CRM_Core_DAO::triggerRebuild('civicrm_contact');"
  cv php:eval "CRM_Core_DAO::dropTriggers('civicrm_contribution');"
  cv php:eval "CRM_Core_DAO::triggerRebuild('civicrm_contribution');"`
  Any ideas of what else to try I would appreciate it.
  
  Thanks,
  username_0
  
  **Tags:** civicontribute, database
  
  > **Comments:**
  > **username_1**: Have you tried the standard trigger rebuild? https://example.com/civicrm/menu/rebuild?reset=1&triggerRebuild=1  
  > **username_0**: Yes, I started with that a couple of times before pulling out any code.  Thanks!  
  > **username_2**: Is there any information about what trigger is causing this error? Do you have logging enabled (civicrm/admin/setting/misc?reset=1)  What do you get when you run the following sql query? "show triggers like 'civicrm_contact%';"  
  > **username_0**: @username_2 Strwart, I do not have logging enabled.  When I do the query you gave me I get one on insert query that is too long to post here. I tried running the drop triggers again to see if it goes away and it does not. Can I safely drop it? Thanks! Happy Thanksgiving!  
  > **username_2**: Assuming no customisations are involved it's totally fine to manually delete the trigger then run rebuild triggers via the drupal rebuild.   What is the trigger of the error - can you replicate it? What is the calling function?  
  > **username_0**: The thing I got to work in the end was to delete the two triggers that were there for on create and on update and then install 5.19.3.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2023-02-01. Score: 3
  
  You can also use the API with `cv`, `drush`, or `wp-cli` to call `System.flush` with the parameter `triggers=TRUE`. E.g. `cv api System.flush triggers=TRUE`.
  
  
  ---
  
  