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 »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Cannot make any changes to CiviCRM - DB Error: Constraint violation
Pages: [1]

Author Topic: Cannot make any changes to CiviCRM - DB Error: Constraint violation  (Read 757 times)

Lionsharz

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 0
    • www.ulearnschool.com
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7
  • PHP version: 5.3 / 5.4
Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 25, 2014, 01:48:06 pm
Hi,

Fresh install 4.4.4 I cannot edit anything - once I press save the following error is returned...  Any ideas?

Code: [Select]
Sorry but we are not able to provide this at the moment.
DB Error: constraint violation
Error Details
Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`stage_civinew`.`civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452
Additional Details:
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  4 , 'civicrm_contact,4' ,  4686 ,  20141025214536 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`stage_civinew`.`civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  4 , 'civicrm_contact,4' ,  4686 ,  20141025214536 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`stage_civinew`.`civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  4 , 'civicrm_contact,4' ,  4686 ,  20141025214536 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`stage_civinew`.`civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
)
Return to home page.

Thanks for any help you can give!

N
www.ulearnschool.com

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 25, 2014, 01:50:20 pm
If this is a fresh install, I'm not sure why you did not install the latest version. If you have no data then you've got nothing to lose by re-installing with 4.5.2 or at least 4.4.8.
Try asking your question on the new CiviCRM help site.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 26, 2014, 04:40:08 am
Coleman's suggestion makes sense. It seems your problem has to do with logging that you enabled, so if you can disable that, it might work also.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Lionsharz

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 0
    • www.ulearnschool.com
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7
  • PHP version: 5.3 / 5.4
Re: Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 26, 2014, 09:36:43 am
thanks for the response guys.

What happened here was we had 2 Drupal installs (stage and live) pointing to the same CiviCRM database. The sites were roughly the same but I ran Backup & Migrate from the live back to stage. Everything seemed to work ok but then I couldn't make any changes to civicrm. I don't want to upgrade at this time - all I wanted to do was move the database under the live site as we had finished ou development work for the time being.

I cannot turn off logging through the UI (it throws an error). Is there any way to disable logging from inside the database?

www.ulearnschool.com

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 26, 2014, 09:45:00 am
I'd check your Backup & Migrate settings and see if you excluded any tables from the backup.  You might also want to use mysqldump or PhpMyAdmin instead of Backup & Migrate and see if that gives you better luck.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

Lionsharz

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 0
    • www.ulearnschool.com
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7
  • PHP version: 5.3 / 5.4
Re: Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 26, 2014, 10:22:06 am
no it wasn't excluding any tables. The B&M is only for the Drupal install -not civicrm...
www.ulearnschool.com

Lionsharz

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 0
    • www.ulearnschool.com
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7
  • PHP version: 5.3 / 5.4
Re: Cannot make any changes to CiviCRM - DB Error: Constraint violation
October 30, 2014, 08:53:31 am
The issue came from the export from PhpMyAdmin. I needed to export again unchecking the checkbox for 'check for foreign keys' I played around with some other settings on the export page and then re-imported. It came good after that.
www.ulearnschool.com

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Cannot make any changes to CiviCRM - DB Error: Constraint violation

This forum was archived on 2017-11-26.