Answers.Body: <p>I was able to create a script to revert in bulk.  I needed to look up the <code>log_conn_id</code> value associated with the bulk change I made.  I made the change using the API import, but any change that happens in a single connection can be reverted.  Simply change the value of <code>$log_conn_id</code> in the script below, and change <code>$tablesToRevert</code> to include the table(s) that need reversion.</p>
  
  
  
  <pre><code>#!/usr/bin/php
  &lt;?php
  eval(`cv php:boot`);
  
  $log_conn_id = '5dcf086e9a837';
  $log_date = NULL;
  $tablesToRevert = ['civicrm_address'];
  
  $reverter = new CRM_Logging_Reverter($log_conn_id, $log_date);
  $differ = new CRM_Logging_Differ($log_conn_id, $log_date);
  $diffs = $differ-&gt;diffsInTables($tablesToRevert);
  $reverter-&gt;setDiffs($diffs);
  $reverter-&gt;revert();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-21T17:04:34.090Z
Answers.LastActivityDate: 2020-04-21T17:04:34.090Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I made a bulk update of addresses that turned out to be incorrect.  I have advanced logging enabled.  I can go into each contact's change log and revert the mistake one by one; how can I do this for all the addresses I altered?</p>
  
Tags: <import><logging>
Title: How can I revert a set of bulk changes to the database?
ThreadText: # How can I revert a set of bulk changes to the database?
  
  (Asked by: username_0 on 2020-04-21)
  
  I made a bulk update of addresses that turned out to be incorrect. I have advanced logging enabled. I can go into each contact's change log and revert the mistake one by one; how can I do this for all the addresses I altered?
  
  **Tags:** import, logging
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-04-21. Score: 6
  
  I was able to create a script to revert in bulk. I needed to look up the `log_conn_id` value associated with the bulk change I made. I made the change using the API import, but any change that happens in a single connection can be reverted. Simply change the value of `$log_conn_id` in the script below, and change `$tablesToRevert` to include the table(s) that need reversion.
  
  ```
  #!/usr/bin/php
  <?php
  eval(`cv php:boot`);
  
  $log_conn_id = '5dcf086e9a837';
  $log_date = NULL;
  $tablesToRevert = ['civicrm_address'];
  
  $reverter = new CRM_Logging_Reverter($log_conn_id, $log_date);
  $differ = new CRM_Logging_Differ($log_conn_id, $log_date);
  $diffs = $differ->diffsInTables($tablesToRevert);
  $reverter->setDiffs($diffs);
  $reverter->revert();
  
  ```
  
  
  ---
  
  