Error when uploading Address HierarchyBahmni v. 0.87

I worked with @binduak to resolve issue.

Based on this error in the openmrs log: Caused by: java.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (openmrs.address_hierarchy_entry, CONSTRAINT parent-to-parent FOREIGN KEY (parent_id) REFERENCES address_hierarchy_entry (address_hierarchy_entry_id) ON DELETE CASCADE) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (openmrs.address_hierarchy_entry, CONSTRAINT parent-to-parent FOREIGN KEY (parent_id) REFERENCES address_hierarchy_entry (address_hierarchy_entry_id) ON DELETE CASCADE)

She first had me do the following in the db:

  1. set foreign_key_checks=0;
  2. delete from address_hierarchy_entry;
  3. INSERT INTO openmrs.address_hierarchy_entry (name, level_id, parent_id, user_generated_id, latitude, longitude, elevation, uuid) VALUES (‘Chattisgarh’, 3, null, null, null, null, null, ‘379e8e56-dd36-42c5-9b35-04ec5842c123’)
  4. set foreign_key_checks=1;

I then was successfully able to import my address hierarchy with no errors.
Thank you so much @binduak! Issue resolved!

3 Likes