[仅限PaaS]{class="badge informative" title="仅适用于云项目(Adobe管理的PaaS基础架构)和内部部署项目上的Adobe Commerce 。"}

ACSD-60989:通过声明性架构修改带有外键的列会在MariaDB上导致错误

ACSD-60989修补程序修复了以下问题:通过MariaDB上的声明性架构修改带有外键的列会导致由于外键约束而出现安装程序升级错误。 安装Quality Patches Tool (QPT) 1.1.78时,此修补程序可用。 修补程序ID为ACSD-60989。 请注意,此问题已在Adobe Commerce 2.4.8中修复。

受影响的产品和版本

为Adobe Commerce版本创建了修补程序:

  • Adobe Commerce(所有部署方法) 2.4.6-p6

与Adobe Commerce版本兼容:

  • Adobe Commerce(所有部署方法)>=2.4.4 <2.4.8
NOTE
该修补程序可能适用于具有新Quality Patches Tool发行版本的其他版本。 要检查修补程序是否与您的Adobe Commerce版本兼容,请将magento/quality-patches包更新到最新版本,并在Quality Patches Tool:搜索修补程序页面上检查兼容性。 使用修补程序ID作为搜索关键字来查找修补程序。

问题

由于安装程序升级期间的外键约束错误,通过MariaDB上的声明性架构修改带有外键的列失败。

重现步骤

  1. 转到​Admin > Stores > Settings > Order Status

  2. 单击​Create New Status,在所有字段中输入​test,然后保存。

  3. 单击​Assign Status to State

    1. 将​ Order Status ​设置为​测试
    2. 将​ Order State ​设置为​已接收
    3. 保存分配。
  4. 创建、注册和启用自定义模块,并将以下内容添加到db_schema.xml

    code language-none
    <?xml version="1.0"?>
    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/etc/db_schema.xsd">
        <table name="sales_order_status">
            <column xsi:type="varchar" name="status" nullable="false" length="64" comment="Order Status"/>
        </table>
        <table name="sales_order_status_state">
            <column xsi:type="varchar" name="status" nullable="false" length="64" comment="Order Status"/>
        </table>
        <table name="sales_order_status_label">
            <column xsi:type="varchar" name="status" nullable="false" length="64" comment="Order Status"/>
        </table>
    </schema>
    
  5. 运行以下命令:

    code language-none
    bin/magento setup:upgrade
    

预期的结果

安装程序升级成功完成,并且没有外键约束错误。

实际结果

安装程序升级期间出错:

Unable to apply patch Vendor\Sales\Setup\Patch\Schema\DataPatch for module Vendor_Sales.
Original exception message:
SQLSTATE[HY000]: General error: 1833 Cannot change column 'status': used in a foreign key constraint
'SALES_ORDER_STATUS_LABEL_STATUS_SALES_ORDER_STATUS_STATUS'
of table 'sales_order_status_label'

应用修补程序

要应用单独的修补程序,请根据您的部署方法使用以下链接:

相关阅读

要了解有关Quality Patches Tool的更多信息,请参阅:

recommendation-more-help
c2d96e17-5179-455c-ad3a-e1697bb4e8c3