1

I have a good installation of CiviCRM on Wordpress, but now i want to upgrade to version 4.6.5 and when ik upgrade, the upgrade stops at 4.6.alpha7

I am trying for 4 hours to get an solution So i have tried to export the structure and data end make a new database with the original structure imports. But nothing will work..

EDIT: I have checked all the tables with a compare program, Left= Current version 4.5.2 / working civicrm (Backup / before Upgrade) Right= Original civicrm.mysql version 4.5.2

RESULT: Only tables civicrm_value_**** are not in the right (original) version.

EDIT 2: I can upgrade to version 4.5.8 without problems. If i want to upgrade then to 4.6.6 It will also stop at 4.6.alpha7 (error below)

I have also checked if there is a table civicrm_mailing_abtest but this table does not exist.

I hope someone can help me to solve this problem.

Thanks a lot. It is a fantastic plugin!! ( CiviCRM )

With kind regards,

Mark

This is the error:

[Error: Upgrade DB to 4.6.alpha7]
Fout Veld   fout waarde
Type    DB_Error
Code    -1
Message DB Error: unknown error
Mode    16
UserInfo    ALTER TABLE civicrm_mailing_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1215 ** Cannot add foreign key constraint]
DebugInfo   ALTER TABLE civicrm_mailing_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1215 ** Cannot add foreign key constraint]
PEAR_Exception: DB Error: unknown error in unknown on line unknown
- DB_Error: DB Error: unknown error in unknown on line unknown
Exception trace

1 Answer 1

2

I had a similar issue upgrading from 4.5.8 to 4.6.4, what worked for me was to manually remove the civicrm_mailing_abtest table from the database. Restore your database backup before the upgrade and login to mysql

Update: To restore your backup database:

mysql -u root -p // login to mysql

drop database civicrm; // delete the current database, the one is failing to upgrade

create database civicrm; // create a new empty database

quit // logout from mysql

Restoring the database backup

mysql -u root -p -h localhost civicrm < /path/to/your/database/backup/civicrm-database-backup.sql // write the backup to the new empty database

Replace "/path/to/your/database/backup" with your backup directory and "civicrm-database-backup.sql" with the name of your Civicrm backup SQL file.

Check for the existing civicrm_mailing_abtest table

mysql -u root -p

use civicrm; // replace civicrm with the name of your database

show tables; // it will give you a list with the civicrm database tables

If the civicrm_mailing_abtest is listed in the output, remove it, as it shouldn't be there, the A/B Test mailing was introduced in CiviCRM 4.6

drop table civicrm_mailing_abtest; // this will remove the table

After that proceed with the upgrade again.

Hope this helps

Update 2: If you have permission errors after the restore, you will need to grant permission to the civicrm mysql user

mysql -u root -p

grant all on civicrm.* to 'username' identified by 'password';

flush privileges;
3
  • This answer should really include a DROP DATABASE civicrm and CREATE DATABASE civicrm before restoring the database backup. Restoring a database backup only overwrites tables that existed in the backup; newly-created tables are NOT written over. That's what leads to this problem in the first place! Aug 3, 2015 at 15:23
  • Sorry about that, I have updated the answer with restore instructions
    – Andrei
    Aug 3, 2015 at 16:33
  • Run this in mysql: SHOW ENGINE INNODB STATUS\G, there should be an Foreign Key errors section in the output. Paste the result here.
    – Andrei
    Aug 6, 2015 at 21:36

Your Answer

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

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