I'm currently working on updating a Drupal site from 6.38 to 7.59, with a MySQL 5.7.21 DB and PHP 5.3.29.
On running the update script, it fails on update 7061 of the update module, due to a MySQL error: "Error Code: 1171. All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead" in response to "CREATE TABLE system_update_7061 ( `vid` INT DEFAULT NULL, PRIMARY KEY (`vid`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Stores temporary data for system_update_7061.'"
I wound up executing the table creation query by hand without the DEFAULT NULL
, and was able to complete the update as normal. I dug into this a little bit, and it seems that many contributed modules have resolved this simply by adding a 'not null' => TRUE
to the table creation (in this case, at system.install line 2871).
I'm wondering if due to this behavior in MySQL 5.7, if includes/database/mysql/schema.inc (createTableSql, ~ line 92) should instead be modified to automatically add the not null if the field is in the array of primary keys. If so, then I guess this issue component needs to get switched.
I can submit a patch if desired, I just haven't done any Drupal contributions to date (and I'm new to the ecosystem as a whole).
Comment | File | Size | Author |
---|---|---|---|
#2 | system-update-2981248-2.patch | 644 bytes | mfb |
Comments
Comment #2
mfbThis is also preventing tests from passing in the MySQL 5.7 environment, so let's fix it.
Comment #4
mfbI guess that was a heisenfailure
Comment #5
mfb@LFP6 or anyone else, feel free to review this patch :)
Comment #6
mfbAdding Drupal 7.60 target as it would be nice to run automated tests on MySQL 5.7
Comment #7
sjerdoLGTM +1
Comment #8
mfbThere's an older duplicate issue @ #2665362: D7 upgrades fail with mysql 5.7:
Comment #9
gregglesSince the change is the same and the other issue is older, I guess this should be marked as a duplicate?
Would be great to get your +1/rtbc on that issue.
Would also be great if you could look at #2615496: A serial/primary key field can not be added to an existing table for some databases!
Comment #10
joseph.olstadthis didn't make it into 7.60, bumping to 7.61
Comment #11
Anaconda777 CreditAttribution: Anaconda777 commentedHi,
Sorry: it was wrong place to post this.
Comment #12
sjerdoComment #13
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedLooks good to me, marking for commit.
Pol, please include people from https://www.drupal.org/project/drupal/issues/2665362 to get credit here.
Thanks!
Comment #15
PolLooks good to me as well.
Updating the credits.
Thanks !
Comment #16
PolComment #17
PolUpdating credits again.
Comment #19
PolFixed, thanks !
Comment #21
joseph.olstadThis is fixed, thanks everyone!
Removing the tags.