How are you meant to do an upgrade with existing quiz data in your db? I get errors when trying to update:
Cannot add unique key result_answer to table quiz_node_results_answers: unique key already exists. [error]
Performed update: quiz_update_7501 [ok]
SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead [error]
Performed update: quiz_question_update_7500 [ok]
Cannot add field quiz_multichoice_user_answers.result_answer_id: field already exists. [error]
Performed update: multichoice_update_7502 [ok]
SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE insteadIt's pretty clear the addition of new pks etc.. breaks existing data - is there something I'm missing to do the upgrade?
Comments
Comment #2
benstjohn commentedComment #3
benstjohn commentedComment #4
djdevin`drush updb` should do it, but it looks like it already failed. Is this the second time you ran drush updb? It's saying the keys in 5.x are already there.
Comment #5
benstjohn commentedThanks for the response, the previous errors may have been after attempting a couple things. Here is a what I get after running updb on a fresh db with existing quiz data:
The main error that is giving me grief is Primary Key errors. I'm not entirely sure I understand what they're saying? Is it saying existing data is resulting in NULL primary keys? Also I'm finding it isn't creating the quiz_result_type table. All I've done is replace my existing quiz module with this version and tried to run updb is there steps I'm missing?
Comment #6
benstjohn commentedA re-install works, naturally, but it blows all my data away.
Comment #7
djdevinHi,
Thanks for the info. Running drush updb is exactly what you are supposed to do and 4.x to 5.x is supported. But somehow it looks like your 4.x install has a table format that the 5.x upgrade is not expecting.
Can you provide me the output of "SHOW CREATE TABLE quiz_node_results_answers" on your old 4.x install?
Comment #8
benstjohn commentedCREATE TABLE `quiz_node_results_answers` (
`result_id` int(10) unsigned NOT NULL,
`question_nid` int(10) unsigned NOT NULL,
`question_vid` int(10) unsigned NOT NULL,
`tid` int(10) unsigned DEFAULT NULL,
`is_correct` tinyint(3) unsigned NOT NULL DEFAULT '0',
`is_skipped` tinyint(3) unsigned NOT NULL DEFAULT '0',
`points_awarded` tinyint(4) NOT NULL DEFAULT '0',
`answer_timestamp` int(10) unsigned NOT NULL,
`number` smallint(6) NOT NULL DEFAULT '1',
`is_doubtful` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`result_id`,`question_nid`,`question_vid`),
KEY `result_id` (`result_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Table storing information about the results for the...';
Comment #9
benstjohn commentedI did see the UTF8 4 byte warning but didn't really think that was my issue ..
Comment #10
djdevinAre you running MySQL 5.7 by any chance?
Comment #12
djdevinI confirmed this is an issue with MySQL 5.7. Unfortunately it's an issue with Drupal 7 core that affects core and other modules so you'll have to patch core to get it to upgrade correctly or downgrade to MySQL 5.6.
Here are the core issues that describe it:
#2665362: D7 upgrades fail with mysql 5.7:
and
#2615496: A serial/primary key field can not be added to an existing table for some databases
I made a change to Quiz core to fix #2665362: D7 upgrades fail with mysql 5.7: . But you'll need to patch core to fix #2615496: A serial/primary key field can not be added to an existing table for some databases which we can't fix in Quiz.
I was able to upgrade Quiz doing the following:
1) Get the latest Quiz 7.x-5.x
2) Patch core with #2615496: A serial/primary key field can not be added to an existing table for some databases
3) drush updb
After Quiz successfully upgrades you could unpatch core.
Comment #13
benstjohn commentedThanks so much I'll give that a go.
Comment #14
djdevinComment #16
ron collins commentedThis specific patch worked for me
https://www.drupal.org/files/issues/d7-2615496-mysql_schema_add_field_se...
I had to first roll the db back to before the attempt to run drush updb, of course.