db_schema.xml 错误自动增量列没有索引。列 - “id”,表 - “unicode_file_store”,unicode_file_customer_group

问题描述 投票:0回答:1

我已经创建了 db_schema.xml 当我运行

php bin/magento setup:upgrade
命令时,出现此错误

自动增量列没有索引。列 - “id”,表 - “unicode_file_store”自动增量列没有索引。列 - “id”,表 - “unicode_file_customer_group”

任何人都可以帮助我为什么我会收到此错误

提前致谢

<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:DB/TestSchema/etc/db_schema.xsd">
    <table name="unicode_file" resource="default" engine="innodb" comment="Unicode File Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Id"/>
        <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" comment="Product Id"/>
        <column xsi:type="text" name="file_path" nullable="false" comment="File Url"/>
        <column xsi:type="varchar" name="file_name" length="255" nullable="false" comment="File Name"/>
        <column xsi:type="text" name="file_url" nullable="false" comment="File Link"/>
        <column xsi:type="int" name="file_size" padding="10" nullable="false" default="0" comment="File Size"/>
        <column xsi:type="varchar" name="file_type" length="255" nullable="false" default="" comment="File Type"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="PRODUCT_ID_FOREIGN" table="unicode_file"
                    column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id"
                    onDelete="CASCADE"/>
    </table>

    <table name="unicode_file_store" resource="default" engine="innodb" comment="Unicode File Store Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" primary="true" comment="Id"/>
        <column xsi:type="int" name="file_id" padding="10" unsigned="true" nullable="false" comment="File Id"/>
        <column xsi:type="smallint" name="store_id" padding="10" unsigned="true" nullable="false" default="0" comment="Store Id"/>
        <column xsi:type="varchar" name="label" length="255" default="null" nullable="false" comment="Label"/>
        <column xsi:type="smallint" name="is_visible" nullable="false" default="0" comment="Is Visible"/>
        <column xsi:type="int" name="position" unsigned="true" nullable="false" comment="Position"/>
        <column xsi:type="smallint" name="show_for_ordered" nullable="false" default="0" comment="Show only if a Product has been Ordered"/>
        <column xsi:type="smallint" name="customer_group_is_default" nullable="false" default="1" comment="Customer Group is from store_id=0"/>
        
        <constraint xsi:type="foreign" referenceId="FILE_ID_FOREIGN" table="unicode_file_store" 
                    column="file_id" referenceTable="unicode_file" referenceColumn="id"
                    onDelete="CASCADE"/>
    </table>

    <table name="unicode_file_customer_group" resource="default" engine="innodb" comment="Unicode File Customer Group Table">
       <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" primary="true" comment="Id"/>
       <column xsi:type="int" name="file_id" padding="10" unsigned="true" nullable="false" comment="File Id"/>
       <column xsi:type="smallint" name="store_id" padding="10" unsigned="true" nullable="false" default="0" comment="Store ID"/>
       <column xsi:type="smallint" name="customer_group_id" padding="10" unsigned="true" nullable="false" primary="true" comment="Customer Group Id"/>

       <constraint xsi:type="foreign" referenceId="FILE_ID_FOREIGN" table="unicode_file_customer_group" 
                    column="file_id" referenceTable="unicode_file" referenceColumn="id"
                    onDelete="CASCADE"/>
    </table>
</schema>
magento2 db-schema
1个回答
0
投票

您需要为表定义主键。

        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>

在两个表的表结束标记之前添加上述代码。

© www.soinside.com 2019 - 2024. All rights reserved.