Module removed but Tables remaining in database in Magento2
문제
I have created one module/extension using installer script in magento2.
After that I removed it, but tables in database still remain as it is.
can anyone tell me how to uninstall module/extension completely and remove extension's/module's tables from database?
해결책
If you install the module via composer, you can have create the Setup/Uninstall.php
file that will be executed when running bin/magento module:uninstall -r [Namespace]_[Module]
.
The Uninstall.php
file should look like this:
<?php
namespace Namespace\Module\Setup;
class Uninstall implements \Magento\Framework\Setup\UninstallInterface
{
public function uninstall(
\Magento\Framework\Setup\SchemaSetupInterface $setup,
\Magento\Framework\Setup\ModuleContextInterface $context
) {
if ($setup->tableExists('table_name_here')) {
$setup->getConnection()->dropTable('table_name_here');
}
}
}
If you installed the module manually, you will need to cleanup your database manually also buy dropping the tables the module added.
제휴하지 않습니다 magento.stackexchange