Magento2 – How to Change Column Length in Table sales_order

magento2sales-order

I'm new to Magento. I want to store 3rd party order id and customer id in column ext_order_id and ext_customer_id in table sales_order.

The problem is these 2 columns have length 32, so I altered the table to set it to 50. However, every time I ran command bin/magento setup:upgrade, the column length was reset back to 32, and data in that column was truncated.

Any solution to store 50 characters in those columns?
Thanks

Best Answer

create a db_schema.xml in a module of yours and update it there example here: https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/db-schema.html

Related Topic