0

So here is the issue - that I think was caused by a merger of contacts without transferring the related fields to the new contact. I have a contact, that seems to be missing a large number of historical records.

I managed to track down their old contact record ID (13) by having them send me some old emails and found all their old records using phpmyadmin by searching for 13 in column "contact_ID" in all tables.

Contact ID 13 does not exist in the database.

Can I create a new contact in CiviCRM and then change its ID via phpmyadmin to 13, will it automatically "reconnect" all the records to this newly created contact?

Edit: tried this, got the following error: #1451 - Cannot delete or update a parent row: a foreign key constraint fails

(`database_name`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)

Or should I just create a contact manually in civicrm_contact via phpmyadmin and set its id value to 13?

Edit: would I have to create a new hash?

Would either of these options work?

6
  • interesting idea (the first one i mean). you may still be missing lots of other data as i theory data in other tables that reference your deleted contact should also have been deleted. so curious about what tables didn't clear the data out. if you have logging on the the data should be recorded in the log tables but is more painful to reconstruct
    – petednz - fuzion
    Jun 16, 2022 at 19:51
  • there is also a risk that when you create your new contact, more rows with the new contact_ID will be created and those will potentially get orphaned when you do your switcheroo on the contact ID
    – petednz - fuzion
    Jun 16, 2022 at 19:53
  • So #1 did not work - I am also unsure about #2 because of the hash - would I just have to generate another random hash?
    – themak
    Jun 16, 2022 at 20:31
  • Also you are right - they are all in the log, not in the main database fields, so none of that would work - this is going to be a pain. Is there a guide on how to restore data from logs?
    – themak
    Jun 16, 2022 at 20:35
  • I managed to restore all these records via the logs, it was exhausting, but im glad its resolved.
    – themak
    Jun 21, 2022 at 17:29

1 Answer 1

0

In Civi, if you use "Advanced Search" there is an option to Search in Trash which contains deleted contacts. Contacts that have been deleted during the merging process should show up there. You can leave the other search options blank in order to see all previously deleted contacts too. No need to go through the tables in phpmyadmin.

1
  • Unfortunately, not there either. Record is completely gone.
    – themak
    Jun 18, 2022 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.