0

I have created an extension with the schema. It is installed correctly and tables are created correctly in the database.

But, now I want to uninstall that extension.

But with uninstall, I also want to delete the tables which were created during the installation of the same extension.

is there any way to do this?

1
  • Login to your database , 1. run this query to show the table you want to delete is there show tables; , 2. run drop table table_name , 3 run query Delete from setup_module where module=Namespace_Module , 4 Flush magento cache. 5 php bin/magento cache:flush, php bin/magento setup:upgrade, php bin/magento setup:static-content:deploy Commented Oct 3, 2018 at 14:28

1 Answer 1

2

For uninstalling the extension, you have to create a Setup/Uninstall.php file.

in that file for uninstall function, add following lines to drop your module table.

public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        if ($setup->tableExists('module_table_name')) {
            $setup->getConnection()->dropTable('module_table_name');
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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