CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Deleting unneeded import/export mapping
Pages: [1]

Author Topic: Deleting unneeded import/export mapping  (Read 1326 times)

Erich

  • I post occasionally
  • **
  • Posts: 84
  • Karma: 1
Deleting unneeded import/export mapping
July 20, 2010, 08:03:42 pm
I wish to delete an import/export mapping from "CiviCRM » Administer CiviCRM » Import/Export Mappings" but am getting the following:

Database Error Code: Cannot delete or update a parent row: a foreign key constraint fails (`conservative_demo/civicrm_saved_search`, CONSTRAINT `FK_civicrm_saved_search_mapping_id` FOREIGN KEY (`mapping_id`) REFERENCES `civicrm_mapping` (`id`)), 1451

How do I identify (and delete) the saved search that appears to be causing the problem?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Deleting unneeded import/export mapping
July 20, 2010, 08:24:03 pm

the easiest way might be to look into the DB tables (civicrm_mapping, civicrm_saved_search, civicrm_group) and find out what smart group is using the mapping for the search

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Erich

  • I post occasionally
  • **
  • Posts: 84
  • Karma: 1
Re: Deleting unneeded import/export mapping
July 20, 2010, 10:42:26 pm
I can get the mapping ID from the civicrm_mapping table, and I can see which civicrm_saved_search uses that mapping ID... but the only thing in the civicrm_saved_search record that looks like it might point to something in civicrm_group is the form_values field, which contains:

a:7:{s:5:"qfKey";s:32:"bb7aea1caf174fd24747f9ce19cf04c6";s:6:"mapper";a:2:{i:1;a:1:{i:0;a:2:{i:0;s:10:"Individual";i:1;s:9:"custom_50";}}i:2;a:1:{i:0;a:1:{i:0;s:0:"";}}}s:8:"operator";a:2:{i:1;a:1:{i:0;s:11:"IS NOT NULL";}i:2;a:1:{i:0;s:0:"";}}s:5:"value";a:2:{i:1;a:1:{i:0;s:0:"";}i:2;a:1:{i:0;s:0:"";}}s:4:"task";s:2:"13";s:8:"radio_ts";s:6:"ts_all";s:11:"uf_group_id";s:0:"";}

Needless to say, I don't know how to decode this ;-)

I will want to keep the smart group that's using the mapping for the search, but "decouple" it from the mapping (so I can delete it).

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Deleting unneeded import/export mapping
July 21, 2010, 12:19:36 am

check civicrm_group, it has an FK to civicrm_saved_search

hmm, not very sure why u want to decouple it. i suspect you are using search builder and hence the mapping is important. If i were you, i would probably not touch those tables (unless u really really know what u r doing)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Erich

  • I post occasionally
  • **
  • Posts: 84
  • Karma: 1
Re: Deleting unneeded import/export mapping
July 21, 2010, 07:43:51 pm
Yes, I used search builder to create a smart group (so yes I want to keep the smart group).

I then selected the "export" option from the smart group results and selected the option to create an export mapping.  It was just a test, to see what the exported results would look like.  It is this mapping -- appropriately named "Test_Export" -- that I now want to delete (i.e. as if I had never elected to export the results of my smart group search).

FWIW, here are the error details when I try to delete the mapping from "CiviCRM » Administer CiviCRM » Import/Export Mappings"

Array
(
    [callback] => Array
        (
            
  • => CRM_Core_Error
  • [1] => handle
            )

        [ code] => -3
        
[message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => DELETE FROM civicrm_mapping  WHERE (  civicrm_mapping.id = 5 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`conservative_demo/civicrm_saved_search`, CONSTRAINT `FK_civicrm_saved_search_mapping_id` FOREIGN KEY (`mapping_id`) REFERENCES `civicrm_mapping` (`id`))]
    [type] => DB_Error
    [user_info] => DELETE FROM civicrm_mapping  WHERE (  civicrm_mapping.id = 5 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`conservative_demo/civicrm_saved_search`, CONSTRAINT `FK_civicrm_saved_search_mapping_id` FOREIGN KEY (`mapping_id`) REFERENCES `civicrm_mapping` (`id`))]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="DELETE FROM civicrm_mapping  WHERE (  civicrm_mapping.id = 5 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`conservative_demo/civicrm_saved_search`, CONSTRAINT `FK_civicrm_saved_search_mapping_id` FOREIGN KEY (`mapping_id`) REFERENCES `civicrm_mapping` (`id`))]"]
)
« Last Edit: July 21, 2010, 08:06:26 pm by Erich »

Erich

  • I post occasionally
  • **
  • Posts: 84
  • Karma: 1
Re: Deleting unneeded import/export mapping
July 22, 2010, 11:51:24 am
Out of curiosity, I (took a backup of my system and) tried to delete -- using the phpMyAdmin interface -- the civicrm_saved_search entry that references my mapping id, and got:

#1451 - Cannot delete or update a parent row: a foreign key constraint fails (`conservative_demo/civicrm_group`, CONSTRAINT `FK_civicrm_group_saved_search_id` FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search` (`id`))

Sure enough, the group that references this saved search is a group I want to keep.  So -- because when I go to  CiviCRM  » Administer CiviCRM  » Import/Export Mappings I already see a bunch of mappings with blanks in the Name, Description, and Mapping Type fields -- I just ended up just nulling out the name "Test_Export" and that had the same net effect of removing the Test_Export name from the list of mappings that could be deleted.

Presumably, all the null Name/Description/MappingType mappings are created internally by CiviCRM when a smart group is created?  If so, it would be nice if either (a) they are given a non-null name/description/mappingType, or (b) they don't show up at all in CiviCRM  » Administer CiviCRM  » Import/Export Mappings.  (If they *are* internal-to-CiviCRM mappings used by smart groups, then I would vote for not having them show up at all in the list of import/export mappings, since they're not really import/export mappings anyway.)
« Last Edit: July 22, 2010, 11:54:29 am by Erich »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Deleting unneeded import/export mapping
July 22, 2010, 07:28:00 pm

you created that mapping when u did a test export from a search builder type saved search, right?

I'm not very sure why saved_search has an FK to your export mapping, and seems like it is a bug there. If important to you, please consider investigating and finding out what is happening and why. Ping us on IRC if u need help getting started

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Deleting unneeded import/export mapping

This forum was archived on 2017-11-26.