3

Up to versions 2.2 (including it) you could uninstall modules installed via composer and when you did that the method uninstall from Setup/Uninstall.php will be executed.
Basically this was the place to drop the tables that the module added and remove all the data. And do other fancy stuff.
Magento 2.3 now has a declarative schema and patches instead of InstallData.
Is there an uninstall equivalent for magento 2.3 ?
I know that the installSchema and installData and Uninstall still work in Magento2.3, but I want to know if there is an alternative (best practice).

As an exercise, I have a module that creates a table my_table.
On uninstall I want to drop that table and remove from core_config_data all the rows where path like 'my_module/'.

  • 1
    According to the DevDocs if a module is disabled a system upgrade will "rebuild the database schema without the module’s tables, columns, or other elements". So if the module is removed form the config it might be the same? The only problem I see with that is that it might not remove the rows from core_config_data – Daniel Jan 19 at 12:14
  • According to the docs you could add a PatchRevertableInterface and put your core_config_data row removal logic there(the revert method). But looking at the module:uninstall command logic this is only called for non-composer modules for whatever reason. As to tables added with db_schema.xml, disabling the module and running setup:upgrade will surely remove them. SchmaPatch logic (stored procedures and such) are not removed by the actions that remove tables. – vitoriodachef Jun 1 at 20:24

Your Answer

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

Browse other questions tagged or ask your own question.