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?
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();