AD0-E717 practice question 8 of 15

A developer defined a new table in db.schema.xml while creating a new module. What should be done to allow the removal of columns from the database when deleting them from db.schema.xml?

Full set: 77 questions
Answer options
A: The removable columns should be defined in db_schema_whitelist.json. Correct answer
B: The columns should have "removable" attribute set to "true" in the db.schema.xml.
C: The removable columns should be defined in db.schema_blacklist.json.
Correct Answer:
A. The removable columns should be defined in db_schema_whitelist.json.
Explanation

Magento's declarative schema feature, by default, does not perform destructive operations like dropping tables or columns to prevent accidental data loss. To enable these operations, a module must have a dbschemawhitelist.json file. This file acts as a snapshot of the module's database schema. When bin/magento setup:upgrade is run, Magento compares the current dbschema.xml with the dbschemawhitelist.json. If a column exists in the whitelist but has been removed from the dbschema.xml, Magento interprets this as an intentional deletion and will generate the SQL to drop the column from the database.

Why Incorrect

B. The removable="true" attribute is used to indicate that a schema element (like a column or table) can be altered or removed by another module, which is useful for extension compatibility, but it does not enable the drop operation itself.
C. The file db.schemablacklist.json is not a standard file used by Magento's declarative schema process for managing column removal. ---

References

1. Adobe Commerce Developer Documentation, "Declarative schema":

Section: Destructive operations

Content: "By default, declarative schema is configured to run in a safe mode, which does not allow destructive operations... To enable destructive operations, you must generate a dbschemawhitelist.json file... When you run setup:upgrade, Magento compares the dbschema.xml file with the module’s dbschemawhitelist.json file. If the whitelist file contains entries that are not in the dbschema.xml file, it means that these database structures have been removed, and they can be dropped."

URL: https://developer.adobe.com/commerce/php/development/components/declarative-schema/

2. Adobe Commerce Developer Documentation, "Configure declarative schema":

Section: The removable attribute

Content: "The removable attribute indicates that the element is not part of the Magento core schema. The default value is true. Set this attribute to false to prevent an element from being removed." This confirms the attribute's purpose is related to inter-module compatibility and prevention, not enabling the drop mechanism.

URL: https://developer.adobe.com/commerce/php/development/components/declarative-schema/configuration/

Scroll to Top