【问题标题】:Drush site-install dkan fails - "All parts of a PRIMARY KEY must be NOT NULL"Drush 站点安装 dkan 失败 - “主键的所有部分必须不为空”
【发布时间】:2016-11-26 12:46:08
【问题描述】:

我正在尝试通过 drush 创建一个DKAN 站点,但我目前在站点安装方面遇到了一些问题。我已经下载了drush、dkan、mysql,mysql服务器目前运行的是mysql Ver 14.14 Distrib 5.7.13, for osx10.11 (x86_64) using EditLine wrapper版本。

假设root@localhost 的mysql 密码是passw0rd。然后我从我的 dkan/webroot 目录中运行命令drush site-install dkan --db-url="mysql://root:passw0rd@localhost/dkandb"

安装开始,“开始 Drupal 安装。这需要一段时间。”但是大约一分钟后,我得到以下异常:

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

连同 25 项堆栈跟踪:

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} 

有什么想法可以消除SQLSTATE[42000] 错误吗?

【问题讨论】:

  • 按照错误说的做?您还没有显示您的 create 语句是什么样的,因此堆栈转储基本上是无用的。
  • 您运行的是什么版本的 PHP?我已经看到可能导致这种情况的非常古老的 PHP 错误。另外,您是否尝试过非 drush 安装过程?如果您要进行大量此类安装,Drush 是一个合理的工具,但我会在尝试跟踪奇怪问题时将其作为变量消除。

标签: php mysql drupal drush dkan


【解决方案1】:

您使用的是哪个版本的 DKAN?看起来 panelizer 模块上的安装失败。你遇到的同样的事情有一个问题:https://www.drupal.org/node/2659820

您可以尝试在那里直接应用更新。

仅供参考,如果您在 https://github.com/NuCivic/dkan/issues 上开票,您将获得 DKAN 团队更直接的支持。

看起来 DKAN 需要更新到最新版本的 panelizer 才能获得适用于您的错误 https://github.com/NuCivic/dkan/blob/7.x-1.x/drupal-org.make#L110 的修复程序,他们应该在下一个版本中进行修复

【讨论】:

    【解决方案2】:

    您需要查看 MySQL 正在尝试创建的表,如下所示:

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

    一旦你有了它,搜索具有该表名的代码以找到设置无效架构的模块的 .install 文件。

    很可能需要将其添加到字段定义中: 'not null' => TRUE,

    首先检查模块的问题队列,看看它是否是一个已知问题,或者创建自己的问题,然后发布补丁。

    就我而言,我遇到了Make Entity Path Compatible with MySQL 5.7。 Panelizer 问题提到 7 月 25 日的答案不再是问题,因为它已被修复并包含在发行版中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-21
      • 2019-01-10
      • 2016-10-15
      • 2014-09-24
      • 2018-09-07
      • 1970-01-01
      相关资源
      最近更新 更多