Magento, Magento 2

How to convert old script to declarative schema in Magento 2

How to convert old script to declarative schema in Magento 2

In this tutorial, Today I will explain to to you how to convert old script to declarative schema in Magento 2. When you migrate from 2.2.x to greater than 2.3.x then you may need to convert old script files InstallSchema.php , UpgradeSchema.php to declarative schema.

After Magento 2.3.x, if you want to create custom database table then you need to use db_schema.xml file for that. InstallSchema and UpgradeSchema are old script for 2.3.x version.

You may also like this :

To convert your install or upgrade script, run one of the following commands:

bin/magento setup:install --convert-old-scripts=1

bin/magento setup:upgrade --convert-old-scripts=1

Once you execute, this above command you can check in your module. Inside custom module’s etc folder db_schema.xml file will be generated.

That’s it !!!

I hope this blog is easy to understand about how to convert old script to declarative schema in Magento 2. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!!

Tagged ,