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();
}
}
I was creating a new script for my Magento store because I had to add new order attribute, Yous post is very helpful and figured out the issue, here’s another guide which helped me to create script, https://www.cloudways.com/blog/setup-scripts-in-magento-2/. Hope, It will help your readers as well.
Thank you Alex !!!