Answers.Body: <p>For some reason you have the civi setting <code>logging_no_trigger_permission</code> set. Possibly at one time it temporarily solved a different problem.</p>
  <p>You can remove it with <code>DELETE FROM civicrm_setting WHERE name='logging_no_trigger_permission';</code>.</p>
  <p>Then clearing cache or <code>cv flush</code> or visit <code>civicrm/menu/rebuild?reset=1&amp;triggerRebuild=1</code> should rebuild the triggers.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-23T22:33:58.950Z
Answers.Text: It was in civicrm.settings.php, not in database. Out of curiosity: where  do yo get this kind of information, is there a magic source of answers which is different from SE/Google?
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-24T00:36:45.423Z
Answers.Text: I'm a little bit familiar with the feature (doing [PR reviews](https://docs.civicrm.org/dev/en/latest/core/pr-review/) is a good way to find out all kinds of stuff) I just couldn't remember what it was called but using `grep` to find the string "commands you need to run" it showed it pretty quickly.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-23T19:15:16.057Z
Answers.LastActivityDate: 2023-02-23T19:15:16.057Z
Answers.UserDisplayName: Demerit
Body: <p>Have got this after the most recent CiviCRM 5.58.1. update on Drupal 7 ( same udate went fine on WP sites ).</p>
  <p>ConfigAndLog/CiviCRM.trigger63f7a62151e54WPFX4db1365ff9d7f93fb47a7eb13184cce6.sql contains, well, a lot of &quot;delete/insert trigger&quot; instructions; however any attempt executing even a single command, like thisone</p>
  <blockquote>
  <p>CREATE TRIGGER civicrm_campaign_group_after_insert after insert ON civicrm_campaign_group FOR EACH ROW BEGIN  IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_campaign_group (<code>id</code>, <code>campaign_id</code>, <code>group_type</code>, <code>entity_table</code>, <code>entity_id</code>, log_conn_id, log_user_id, log_action) VALUES ( NEW.<code>id</code>, NEW.<code>campaign_id</code>, NEW.<code>group_type</code>, NEW.<code>entity_table</code>, NEW.<code>entity_id</code>, COALESCE(@uniqueID, LEFT(CONCAT('c_', unix_timestamp()/3600, CONNECTION_ID()), 17)), @civicrm_user_id, 'insert')</p>
  </blockquote>
  <p>in phpmyadmin leads to &quot;You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1&quot;</p>
  <p>Looks like this breaks normal system operations and leads to errors like the one below:</p>
  <blockquote>
  <p>[db_error: message=&quot;DB Error: constraint violation&quot; code=-3 mode=callback callback=CRM_Core_Error::exceptionHandler prefix=&quot;&quot; info=&quot;INSERT INTO <code>civicrm_mailing_event_queue</code> (<code>email_id</code> , <code>contact_id</code> , <code>hash</code> ) VALUES ( 6984 ,  7051 , '0828cd3309c1d93d' )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (<code>comedyev_crm_civicrm</code>.<code>civicrm_mailing_event_queue</code>, CONSTRAINT <code>FK_civicrm_mailing_event_queue_job_id</code> FOREIGN KEY (<code>job_id</code>) REFERENCES <code>civicrm_mailing_job</code> (<code>id</code>) ON DELETE CASCADE)]&quot;]
  )</p>
  </blockquote>
  <p>Not quite sure why the triggers weren't created while update; how do I get out from here please?</p>
  
Tags: <drupal><mysql><trigger>
Title: The mysql commands you need to run are stored in
ThreadText: # The mysql commands you need to run are stored in
  
  (Asked by: username_0 on 2023-02-23)
  
  Have got this after the most recent CiviCRM 5.58.1. update on Drupal 7 ( same udate went fine on WP sites ).
  
  ConfigAndLog/CiviCRM.trigger63f7a62151e54WPFX4db1365ff9d7f93fb47a7eb13184cce6.sql contains, well, a lot of "delete/insert trigger" instructions; however any attempt executing even a single command, like thisone
  
  > CREATE TRIGGER civicrm\_campaign\_group\_after\_insert after insert ON civicrm\_campaign\_group FOR EACH ROW BEGIN IF ( @civicrm\_disable\_logging IS NULL OR @civicrm\_disable\_logging = 0 ) THEN INSERT INTO log\_civicrm\_campaign\_group (`id`, `campaign_id`, `group_type`, `entity_table`, `entity_id`, log\_conn\_id, log\_user\_id, log\_action) VALUES ( NEW.`id`, NEW.`campaign_id`, NEW.`group_type`, NEW.`entity_table`, NEW.`entity_id`, COALESCE(@uniqueID, LEFT(CONCAT('c\_', unix\_timestamp()/3600, CONNECTION\_ID()), 17)), @civicrm\_user\_id, 'insert')
  
  in phpmyadmin leads to "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1"
  
  Looks like this breaks normal system operations and leads to errors like the one below:
  
  > [db\_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM\_Core\_Error::exceptionHandler prefix="" info="INSERT INTO `civicrm_mailing_event_queue` (`email_id` , `contact_id` , `hash` ) VALUES ( 6984 , 7051 , '0828cd3309c1d93d' ) [nativecode=1452 \*\* Cannot add or update a child row: a foreign key constraint fails (`comedyev_crm_civicrm`.`civicrm_mailing_event_queue`, CONSTRAINT `FK_civicrm_mailing_event_queue_job_id` FOREIGN KEY (`job_id`) REFERENCES `civicrm_mailing_job` (`id`) ON DELETE CASCADE)]"]
  > )
  
  Not quite sure why the triggers weren't created while update; how do I get out from here please?
  
  **Tags:** drupal, mysql, trigger
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-02-23. Score: 2 | Accepted answer
  
  For some reason you have the civi setting `logging_no_trigger_permission` set. Possibly at one time it temporarily solved a different problem.
  
  You can remove it with `DELETE FROM civicrm_setting WHERE name='logging_no_trigger_permission';`.
  
  Then clearing cache or `cv flush` or visit `civicrm/menu/rebuild?reset=1&triggerRebuild=1` should rebuild the triggers.
  
  > **Comments:**
  > **username_0**: It was in civicrm.settings.php, not in database. Out of curiosity: where  do yo get this kind of information, is there a magic source of answers which is different from SE/Google?  
  > **username_1**: I'm a little bit familiar with the feature (doing [PR reviews](https://docs.civicrm.org/dev/en/latest/core/pr-review/) is a good way to find out all kinds of stuff) I just couldn't remember what it was called but using `grep` to find the string "commands you need to run" it showed it pretty quickly.  
  
  ---
  
  