Magento 2 Upgrade Old Script to Declarative Schema

In this guide, we’ll walk you through the process of Magento 2 upgrade old script to declarative schema. With Magento 2’s declarative schema, developers can better manage database changes, improving efficiency and maintainability.

When you migrate from Magento 2.2.x to 2.3.x or later, it’s important to convert legacy script files like InstallSchema.php and UpgradeSchema.php to the declarative schema format.

Starting from Magento 2.3.x, creating custom database tables now requires using the db_schema.xml file. The InstallSchema.php and UpgradeSchema.php files are no longer used in Magento 2.3.x and beyond for defining database changes. Therefore, upgrading these old scripts to the declarative schema is essential for maintaining compatibility with newer Magento versions.

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

After running the command, check within your custom module. A db_schema.xml file will be automatically generated inside the etc folder of your module

Leave a Reply

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