After having put a lot of time into customizing a CiviCRM installation, I want a way to replicate the configuration / customization / installed-extensions, but start from scratch on the contacts (so that newly added contacts -- after the admin contact and organization -- have contact-ids of 3,4,5,...). Deleting all contacts via the UI doesn't seem to "reset" the next-contact ID counter.

Perhaps one way this could be possible is if there were a means by which all configuration / extensions could be backed up and restored, independent of the data in the system (e.g. contacts, memberships, contributions, etc.). Is this possible somehow? Or is there another way to achieve my goal of "starting over" with non-configuration data?

  • Why do you want to start with a new contact id? If there is a need to have a unique but meaningful contact number you could also use the Identity Tracker extension: github.com/systopia/de.systopia.identitytracker – Jaap Jansma - CiviCooP Jun 6 '18 at 8:59
  • @JaapJansma-CiviCooP a "reset" contact ID isn't the main goal, but rather a fresh CiviCRM database that doesn't have any data-elements in it left-over from previous use of CiviCRM -- so really this goes beyond just contacts to anything that isn't configuration related data. – Mark Jun 6 '18 at 14:47

I would suggest to perform deletion of contact from UI and then reseting the auto increment value through mysql command. Truncating database might loose contact that are not suppose to be deleted like logged in contact id or Default organization contact id or they might be possible to have orphan data for contacts if we directly truncate the table. Here is what i would do

  1. Find Contact
  2. Select All contact
  3. From Action list i will select 'Delete Contact permanently'

Shell in for mysql or in phymyadmin through web and run ALTER TABLE civicrm_contact AUTO_INCREMENT = 1

Note: Backup database before deleting contacts.



| improve this answer | |
  • While this is a bit better than directly removing entries via SQL queries, I am noticing that even after deleting a contact "permanently", there are still residual "Address" entities in the database that were associated with deleted contacts. Is there a way to safely remove these also? – Mark Jun 6 '18 at 2:43
  • Those address may be tied to Events. Can you check if all the address have contact_id as NULL and this address are link to civicrm_loc_block – Pradeep Nayak Jun 6 '18 at 18:52
  • I already manually deleted all the address entities via the API explorer, but their contact_id fields were not NULL. – Mark Jun 7 '18 at 12:59
  • Ohhh in that case they might have tied up with events not sure though – Pradeep Nayak Jun 7 '18 at 13:06

One way is to truncate civicrm_contact database table.

| improve this answer | |
  • I might try this, but would want to be sure that there won't be configuration data that is coupled in some way with the last known state of the contact table. In other words, I want to avoid introducing glitches due to the DB state being changed directly instead of via the civicrm API. – Mark Jun 5 '18 at 19:54
  • There is only one way to test it :) I would suggest to leave default organization contact ID and associated individual contact ID. Which CMS are you using? You can always take a dump of that table in case if something goes wrong – Hassan Farooq Jun 5 '18 at 19:57
  • 2
    There are other tables that are indeed tied to that, especially if you have added custom fields. The answer above to delete all contacts permanently inside CiviCRM and then reset the count is a much better way to do it and ensures that all of their data, registrations, etc is gone. – Jenni Simonis Jun 5 '18 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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