3

What is the use of db_schema_whitelist.json located in Magento Catalog etc directory?

In Magento 2.3 version, I found db_schema_whitelist.json and db_schema.xml files, in the Magento_Catalog module.

Having idea about db_schema.xml, that is related with declarative schema management.

Also found that db_schema_whitelist.json file located in etc directory and it contains GraphQL based attributes that may be require to fetch attributes at frontend.

I want to know that which operations Magento 2 application will consider for db_schema_whitelist.json for Magento_Catalog in terms of GraphQL.

6

db_schema_whitelist.json file provides a history of all tables, columns, keys added with declarative schema. It can be generated manually or created automatically with the following command :

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

RH_Helloworld is module name.

If no module name is specified, then the default behavior is to generate a whitelist for all modules. You can also explicitly set --module-name=all.

Reference

1

The db_schema_whitelist.json file is a way of telling Magento which tables and columns it can safely alter using the db_schema.xml file. It was added to preserve backward compatibility and will be removed in a future version when the install/upgrade script be no longer supported.

In the current dual state where tables and columns can be added/altered/removed either via setup scripts (those located in the Setup folder) or via the new etc/db_schema.xml files, Magento can not know by itself which tables/columns can be safely altered using only the db_schema.xml files. Hence, the db_schema_whitelist.json holds a list of all the DB tables, columns, indexes, constraints, etc that where created via declarative schema and can therefore be safely altered in case it detects any change for those elements in an upgraded db_schema.xml file. Hope it makes more sense now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.