浏览文章

文章信息

Magento2 db_schema.xml表添加|表字段添加|add table feilds 13312

etc/db_schema.xml

<?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="sales_order" resource="sales" engine="innodb" comment="Sales Order">
        <column xsi:type="varchar" name="aiweline_upsell_product_info" nullable="true" length="1000" comment="Upsell 产品信息"/>
    </table>
    <table name="quote" resource="checkout" engine="innodb" comment="Quote">
        <column xsi:type="varchar" name="aiweline_upsell_product_info" nullable="true" length="1000" comment="Upsell 产品信息"/>
    </table>
    <table name="sales_invoice" resource="sales" engine="innodb" comment="Sales Invoice">
        <column xsi:type="varchar" name="aiweline_upsell_product_info" nullable="true" length="1000" comment="Upsell 产品信息"/>
    </table>
</schema>

高级(时间字段1):

<column xsi:type="timestamp" name="created_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created Datetime"/>
<column xsi:type="timestamp" name="updated_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated Datetime"/>

高级(时间字段2)

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="faqs" resource="default" engine="innodb" comment="FAQ Table">
        ........
        <column xsi:type="timestamp" name="created_datetime" nullable="false" default="TIMESTAMP_INIT" comment="Created Datetime"/>
        <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="TIMESTAMP_INIT_UPDATE" comment="Updated Datetime"/>
        ........
    </table>
</schema>

之后,运行php bin/magento setup:upgrade命令。

原创