How to create boolean column in Magento2 using db_schema.xml - Magesan

How to create boolean column in Magento2 using db_schema.xml

How to create boolean column in Magento2 using db_schema.xml

In your db_schema.xml file which should be inside Magesan/Extension/etc/db_schema.xml

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="tableName" resource="default" engine="innodb" comment="Table Comment">
        <column xsi:type="boolean" name="columnName" nullable="false" comment="column comment" />
    </table>
</schema>

Save the file.

You just only need to fire php bin/magento setup:upgrade command and you will see the column will added to table.

Happy Coding…

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>