Magento 2 Create db_schema_whitelist.json File

From Magento 2.3 and the higher version, Magento introduced the declarative schema for install and upgrade database tables and fields.

How to create a schema whitelist:
Following is the syntax to create the db_schema_whitelist.json using the CLI commands in the Magento 2

php bin/magento setup:db-declaration:generate-whitelist --module-name=<Module_Name>

Where, <Module_Name> is your Magento 2 Module Name.
E.g., your Magento 2 module name is Dhairvi_Demo then run following command to generate the db_schema_whitelist.json

php bin/magento setup:db-declaration:generate-whitelist --module-name=Dhairvi_Demo

After run this command, you can see db_schema_whitelist.json file under your module’s etc/ directory.

If you can not see db_schema_whitelist.json file, there please review our blog post Magento 2 db_schema_whitelist.json file not creating to troubleshoot the issue.