QuestionQ14

Working with Databases and EAV

An Adobe Commerce developer is building a Marketplace module (Vendor_ModuleName). The module creates a database table through declarative schema, and the developer now needs to ensure that the table is removed when the module is disabled.

What must the developer do to achieve this?

  • A There is nothing further the developer needs to do. The table will be removed when the module is disabled and bin/magento setup:upgrade is run.
  • B There is nothing further the developer needs to do. The table will be removed when the when bin/magento module:uninstall Vendor_ModuleName is run.
  • C Add a schema patch that implements Magento\Framework\Setup\Patch\PatchRevertableInterface and drops the table in the revert function.
Explanation

When a module that uses declarative schema is disabled, Commerce no longer reads that module’s database-schema configuration. Running bin/magento setup:upgrade reconciles the database with the remaining declared schema and drops the disabled module’s declared table. A PatchRevertableInterface implementation is only needed when a patch must be rolled back during module uninstallation.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!