ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 31 - AD0-E716 discussion

Report
Export

The developer is required to convert a modules database scripts from old install/upgrade setup files to a data patches format and does not want to apply database changes that were already done by install/upgrade scripts.

The current module version is 1.5.4.

What would be the recommended solution to skip changes that were already applied via old format (install/upgrade scripts)?

A.
Implement Patchversioninterface and return 1.5.4 on the getversion() method.
Answers
A.
Implement Patchversioninterface and return 1.5.4 on the getversion() method.
B.
Inside apply() method, check for module version and run the code if version is less than 1.5.4.
Answers
B.
Inside apply() method, check for module version and run the code if version is less than 1.5.4.
C.
This is not possible. A module cannot implement both data patch and install scripts.
Answers
C.
This is not possible. A module cannot implement both data patch and install scripts.
Suggested answer: A

Explanation:

According to the Develop data and schema patches guide for Magento 2 developers, data patches are classes that contain data modification instructions. They are defined in a <Vendor>/<Module_Name>/Setup/Patch/Data/<Patch_Name>.php file and implement MagentoFrameworkSetupPatchDataPatchInterface. Data patches can also implement Patchversioninterface to specify the module version that the patch is associated with. The getVersion() method returns the module version as a string. To skip changes that were already applied via old format (install/upgrade scripts), the developer should implement Patchversioninterface and return 1.5.4 on the getVersion() method. This way, the data patch will only be applied if the module version is greater than or equal to 1.5.4. Verified

Reference: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html

asked 02/10/2024
antonio de simone
36 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first