Magento 2 SQLSTATE [HY000] : General error: 1823 Failed to add the foreign key constraint

标签 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

运行时出错 php -f bin/magento setup:db-schema:upgrade
enter image description here

上一条消息发生的命令

enter image description here

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

Swagger 错误 500

enter image description here

{"0":"Please upgrade your database: Run \"bin/magento setup:upgrade\" from the Magento root directory.\nThe following modules are outdated:\nKlarna_Core data: current version - 4.1.5, required version - 4.2.3\nKlarna_Ordermanagement data: current version - 4.1.2, required version - 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('dispatch', Array, Array)\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"}



Swagger 错误日志

enter image description here

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

管理面板错误

enter image description here
[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)"} []

管理面板错误日志

enter image description here

最佳答案

如果你备份了同一张表,如果外键约束和bkp表一样,当前表mysql会抛出异常,那么修改约束名或者删除现有的约束。

约束名称不应相同。

关于Magento 2 SQLSTATE [HY000] : General error: 1823 Failed to add the foreign key constraint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50690185/

相关文章:

magento - 批量操作或页面切换后管理网格列发生变化 - Magento 1.9

magento - 如何在 Magento 中移动管理菜单项

php - 如何查找哪个文件具有将数据插入magento表中的代码

java - Swagger - 包含模式选项在文档中不可用

e-commerce - 如何在magento中调整媒体图像的大小?

css - Magento 绝对定位主屏幕 CSS 设置

java - Swagger 与 spring MVC 不生成服务文档

java - Swagger-UI 未正确显示

spring-boot - 具有多态性的 Swagger UI 未显示正确的模型

java - Swagger 不够智能,无法处理匿名类型(例如 map )