How to create new coulmn in sales_order_item using db_schema in magento2 - Magento Source24

How to create new coulmn in sales_order_item using db_schema in magento2

How to create new coulmn in sales_order_item using db_schema in magento2

In this Blog Post i'm share with you to How to create new coulmn in sales_order_item using db_schema.xml in magento2


👉 Create a db_schema.xml file in VendorName/ModuleName/etc/db_schema.xml

👉  in this post i have create 3 column is_customized,customized_image and customized_parts using 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_item" resource="default" engine="innodb">

        <column xsi:type="varchar" name="is_customized" nullable="true" length="255" comment="Is Customized"/>

        <column xsi:type="varchar" name="customized_image" nullable="true" length="255" comment="Customized Image"/>

        <column xsi:type="varchar" name="customized_parts" nullable="true" length="255" comment="Customized Parts"/>

    </table>

</schema>


👉 After Done this Above Code then Run Bellow Command - 

  1. php bin/magento setup:upgrade 
  2. php bin/magento setup:static-content:deploy -f 
  3. php bin/magento cache:flush


👉  and check your sales_order_item Databse table : your column is here



Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post