Magento 2 SQLSTATE[HY000]:一般错误:1823 未能添加外键约束

Kar*_*afa 5 magento swagger

大家好,我的 Magento 2 Store 出现错误。例如 API 请求失败,Swagger 给出 500,样式表和 JS 文件无法加载等。

最后,我发现最好的解决方案来创建一个新的Magento安装与新鲜的主题文件,只是复制pub/media所有文件和维修模式去砸前缀所有的表customers_catalog_sales_eav_

这一步使我的新商店工作得很好,但我遇到了新的错误..我无法运行setup:upgrade它显示一条消息:

[PDOException] SQLSTATE[HY000]: General error: 1823 Failed to add the foreign key constraint 'porosec_pororom/CAT_CTGR_PRD_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID' to system tables
Run Code Online (Sandbox Code Playgroud)

我运行时出错 php -f bin/magento setup:db-schema:upgrade

在此处输入图片说明

上一条消息发生的命令

在此处输入图片说明

当我运行composer update它时也会更新许多依赖项,但它需要运行setup:upgrade.

Swagger 错误 500

在此处输入图片说明

{"0":"请升级您的数据库:从 Magento 根目录运行 \"bin/magento setup:upgrade\"。\n以下模块已过时:\nKlarna_Core 数据:当前版本 - 4.1.5,所需版本 - 4.2 .3\nKlarna_Ordermanagement 数据:当前版本 - 4.1.2,所需版本 - 4.1.3","1":"#0 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(121 ): Magento\Framework\Module\Plugin\DbStatusValidator->beforeDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Magento\Framework\App\Request\Http))\n#1 /home/porosec/ public_html/test/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#2 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(135) : Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n# 3 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\ Framework\App\Request\Http))\n#4 /home/porosec/public_html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor ->___callPlugins('调度',数组,数组)\n#5 /home/porosec/public_html/test/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App) \Request\Http))\n#6 /home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch() \n#7 /home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()\n#8 /home/porosec /public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#9 {main}","url":" /test/swagger","script_name":"/test/index.php"}dispatch(Object(Magento\Framework\App\Request\Http))\n#6 /home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework \App\Http->launch()\n#7 /home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch( )\n#8 /home/porosec/public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#9 { main}","url":"/test/swagger","script_name":"/test/index.php"}dispatch(Object(Magento\Framework\App\Request\Http))\n#6 /home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework \App\Http->launch()\n#7 /home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch( )\n#8 /home/porosec/public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#9 { main}","url":"/test/swagger","script_name":"/test/index.php"}php(256): Magento\Framework\App\Http\Interceptor->launch()\n#8 /home/porosec/public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(对象(Magento\Framework\App\Http\Interceptor))\n#9 {main}","url":"/test/swagger","script_name":"/test/index.php"}php(256): Magento\Framework\App\Http\Interceptor->launch()\n#8 /home/porosec/public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(对象(Magento\Framework\App\Http\Interceptor))\n#9 {main}","url":"/test/swagger","script_name":"/test/index.php"}

Swagger 错误日志

在此处输入图片说明

这也是我在管理仪表板中得到的

管理面板错误

在此处输入图片说明

[2018-06-04 23:18:09] main.CRITICAL: Report ID: webapi-5b15c8b17792e; Message: Class "array" does not exist. Please note that namespace must be specified. {"exception":"[object] (Exception(code: 0): Report ID: webapi-5b15c8b17792e; Message: Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Webapi/ErrorProcessor.php:205, LogicException(code: 0): Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Reflection/TypeProcessor.php:139)"} []
Run Code Online (Sandbox Code Playgroud)

管理面板错误日志

在此处输入图片说明

小智 1

如果你备份了同一个表,并且外键约束与bkp表和当前表相同,mysql将抛出异常,因此更改约束名称或删除现有约束。

约束名称不能相同。