Drush site-install dkan fails - "All parts of a PRIMARY KEY must be NOT NULL"

810 views Asked by At

I'm trying to make a DKAN site via drush, and I'm currently running into some issues with the site-install. I've downloaded drush, dkan, and mysql, and the mysql server is currently running with version mysql Ver 14.14 Distrib 5.7.13, for osx10.11 (x86_64) using EditLine wrapper.

Say the mysql password for root@localhost is passw0rd. Then I'm running the command drush site-install dkan --db-url="mysql://root:passw0rd@localhost/dkandb" from inside my dkan/webroot directory.

The installation begins, "Starting Drupal Installation. This takes a while." But after a minute or so, I get the following exception:

exception 'PDOException' with message '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' in /Users/Nicholas/dkan/webroot/includes/database/database.inc:2204

Along with a 25 item stack trace:

Stack trace:
#0 /Users/Nicholas/dkan/webroot/includes/database/database.inc(2204): PDOStatement->execute(Array)
#1 /Users/Nicholas/dkan/webroot/includes/database/database.inc(683): DatabaseStatementBase->execute(Array, Array)
#2 /Users/Nicholas/dkan/webroot/includes/database/schema.inc(664): DatabaseConnection->query('CREATE TABLE {p...')
#3 /Users/Nicholas/dkan/webroot/includes/database/database.inc(2753): DatabaseSchema->createTable('panelizer_entit...', Array)
#4 /Users/Nicholas/dkan/webroot/includes/common.inc(7092): db_create_table('panelizer_entit...', Array)
#5 /Users/Nicholas/dkan/webroot/includes/module.inc(479): drupal_install_schema('panelizer')
#6 /Users/Nicholas/dkan/webroot/includes/install.core.inc(1609): module_enable(Array, false)
#7 [internal function]: _install_module_batch('panelizer', 'Panelizer', Array)
#8 /Users/Nicholas/dkan/webroot/includes/batch.inc(284): call_user_func_array('_install_module...', Array)
#9 /Users/Nicholas/dkan/webroot/includes/form.inc(4714): _batch_process()
#10 /Users/Nicholas/dkan/webroot/includes/install.core.inc(444): batch_process('install.php?pro...', 'http://default/...')
#11 /Users/Nicholas/dkan/webroot/includes/install.core.inc(339): install_run_task(Array, Array)
#12 /Users/Nicholas/dkan/webroot/includes/install.core.inc(77): install_run_tasks(Array)
#13 /usr/local/Cellar/drush/HEAD-c967802/libexec/includes/drush.inc(725): install_drupal(Array)
#14 /usr/local/Cellar/drush/HEAD-c967802/libexec/includes/drush.inc(711): drush_call_user_func_array('install_drupal', Array)
#15 /usr/local/Cellar/drush/HEAD-c967802/libexec/commands/core/drupal/site_install_7.inc(82): drush_op('install_drupal', Array)
#16 /usr/local/Cellar/drush/HEAD-c967802/libexec/commands/core/site_install.drush.inc(245): drush_core_site_install_version('dkan', Array)
#17 [internal function]: drush_core_site_install('dkan')
#18 /usr/local/Cellar/drush/HEAD-c967802/libexec/includes/command.inc(366): call_user_func_array('drush_core_site...', Array)
#19 /usr/local/Cellar/drush/HEAD-c967802/libexec/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#20 [internal function]: drush_command('dkan')
#21 /usr/local/Cellar/drush/HEAD-c967802/libexec/includes/command.inc(185): call_user_func_array('drush_command', Array)
#22 /usr/local/Cellar/drush/HEAD-c967802/libexec/lib/Drush/Boot/BaseBoot.php(73): drush_dispatch(Array)
#23 /usr/local/Cellar/drush/HEAD-c967802/libexec/includes/preflight.inc(88): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#24 /usr/local/Cellar/drush/HEAD-c967802/libexec/drush.php(12): drush_main()
#25 {main} 

Any ideas of what I can do to remove the SQLSTATE[42000] error?

2

There are 2 answers

0
colan On

You need to look at which table MySQL is attempting to create as shown here:

#2 /Users/Nicholas/dkan/webroot/includes/database/schema.inc(664): DatabaseConnection->query('CREATE TABLE {p...')

Once you have that, search through the code with that table name to find the .install file for the module that's setting up an invalid schema.

Most likely, it'll be necessary to add this to the field definition: 'not null' => TRUE,

Check the module's issue queue first to see if it's a known issue, or create your own, and then post a patch.

In my case, I was running into Make Entity Path Compatible with MySQL 5.7. The Panelizer issue mentioned the July 25th answer is no longer a problem as it has been fixed and included in the distro.

0
acouch On

What version of DKAN are you using? It looks like the installation is failing on the panelizer module. There is an issue for the same thing you've experienced: https://www.drupal.org/node/2659820

You could try directly applying the update there.

FYI if you open a ticket on https://github.com/NuCivic/dkan/issues you will get more direct support from the DKAN team.

It looks like DKAN needs to update to the latest version of panelizer to get the fix that applies to your error https://github.com/NuCivic/dkan/blob/7.x-1.x/drupal-org.make#L110 which they should with the next release