While upgrading via drush to the latest stable I encountered the following error:

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: system_update_7061                                                                                                                                                             [ok]

This error was encountered with:
- php 5.5.31
- mysql 5.7.10

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

msti created an issue. See original summary.

msti’s picture

Mysql 5.7.3 adds significant changes: http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-3.html

This patch adds a 'not null' => TRUE to the database field

SuneK’s picture

This is also present in Drupal 7.43 when upgrading from Drupal 6. With PHP 5.6.20 and MySQL 5.7.9.1 I get
PDOException: 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: 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.'; Array ( ) in db_create_table() (line 2720 of D:\Drupal\includes\database\database.inc).
for system_update_7061.
In my case I solved it by changing line 2796 of system.install to

'fields' => array('vid' => array('type' => 'int', 'default' => '0' )),
greggles’s picture

Title: Upgrade fails with mysql 5.7 » D7 upgrades fail with mysql 5.7:

This patch looks good to me. It is probably also important/necessary to add #2615496: A serial/primary key field can not be added to an existing table for some databases to fully fix this problem.

mfb’s picture

mfb’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Drupal 7.60 target

Tests are passing on MySQL 5.7 so setting to RTBC.

joseph.olstad’s picture

Issue tags: -Drupal 7.60 target +Drupal 7.61 target

this didn't make it into 7.60, bumping to 7.61

joseph.olstad’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
Related issues: +#2981248: MySQL 5.7 incompatibility in system upgrade 7061

closing in favour of:

Pol’s picture

This has been fixed in 7.x today.

Thanks all.

joseph.olstad’s picture

C'est moi qui te remercie, Bonne année Pol!