浏览文章

文章信息

Magento2 使用db_schema.xml添加unique字段|Magento2 create unique field using db_schema.xml 13841

示例:

<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="wishlist_item_option">
        <column xsi:type="varchar" name="short_url" nullable="true" length="20" comment="短连接"/>
        <column xsi:type="varchar" name="origin_url" nullable="true" length="1000" comment="原链接"/>
        <constraint xsi:type="unique" referenceId="WISHLIST_ITEM_OPTION_SHORT_URL">
            <column name="short_url"/>
        </constraint>
    </table>
</schema>


原创