Uninstall Setup Script Magento 2

Magento 2 provide us the uninstall module feature which will remove all of the table, data like it hadn’t installed yet.

File: app/code/PHPCodez/First/Setup/Uninstall.php

<?php

namespace PHPCodez\First\Setup;

use Magento\Framework\Setup\UninstallInterface;
 use Magento\Framework\Setup\SchemaSetupInterface;
 use Magento\Framework\Setup\ModuleContextInterface;

class Uninstall implements UninstallInterface {
 public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
 $installer = $setup;
 $installer->startSetup();

$installer->getConnection()->dropTable($installer->getTable('phpcodez_post'));

$installer->endSetup();
 }
 }
Share

2 thoughts on “Uninstall Setup Script Magento 2”

Leave a Reply

Your email address will not be published. Required fields are marked *