How to Create db_schema_whitelist.json in Magento 2

Magento 2 versions from 2.3 have a replacement for traditional install/upgrade schema which is used to maintain the database structure.

From Magento 2 version 2.3, they have introduced the declarative schema file for database (etc/db_schema.xml) which is used to maintain the database structure for a module.

Now you can forget about untidy install/upgrade file and see the latest database structure version of a module in a single file.

For Magento 2 to identify the database schema changes, you need to maintain a file db_schema_whitelist.json against which Magento will compare your database structure from db_schema.xml and decide to update the database structure of your module while executing bin/magento setup:upgrade command.

In order to create the db_schema_whitelist.json in your Magento 2 module, you can run the below command:

php bin/magento setup:db-declaration:generate-whitelist [options]

Where [options] will be,
–module-name[=Modulename] specifies the Module name to generate a whitelist.

Official Magento 2 documentation:

Leave a Reply

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