

The //etc/db_schema.xml file declares a module’s database structure. The following example, extracted from the Catalog/etc/db_schema.xml file, defines the catalog_product_entity_datetime table: Magento prioritizes the declarative schema and executes the declarative install schemas before the data and schema patches. These differences can be represented with atomic SQL operations.

Schema files declare what the database structure should be,Īnd Magento determines the differences between the current table structure and what it should be. Declarative setup eliminates this type of unnecessary work.ĭeclarative setup is based on database structure declarations, and is used in projects such as Doctrine. For example, in one version a new database column might be introduced, only to be removed in the next. The main disadvantage of this approach is that Magento applies changes blindly. That procedure is called migration setup or migration scripts. The Magento installation only knows that a module has an upgrade script, not what versions it affected. Each upgrade script is responsible for checking the required version for each change to apply. For example, if you have a module with version 2.1.8 installed and the latest version is 2.1.11, then the upgrade script changes for 2.1.9, 2.1.10, and 2.1.11 will be applied, in order, when you upgrade to 2.1.11. During the installation process, upgrade scripts apply only those changes that have not been applied yet.


Migrate install/upgrade scripts to declarative schema.Upload your component to the Commerce Marketplace.Roadmap for developing and packaging components.
