Create file name called UpgradeSchema.php from your module Setup folders
Ex: app/code/Vendor/Ecommerce/Setup/UpgradeSchema.php
Here we are going to create column called vendor_isallowstatus
Column name called : vendor_isallowstatus
Table name : vendor_ecommerce
adde below code into your file.
Ex:
if (version_compare($context->getVersion(), ‘2.0.5’) < 0) { //My new upgrade file version is 2.0.5 incase if 2.0.6 then set 2.0.6
}
Step:1
<?php
namespace Vendor\Ecommerce\Setup;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class UpgradeSchema implements UpgradeSchemaInterface{
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context){
if (version_compare($context->getVersion(), '2.0.1') < 0) {
$setup->startSetup();
$setup->getConnection()->addColumn(
$setup->getTable('vendor_ecommerce'),
'vendor_isallowstatus',
['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INT,
'length' => '11',
'nullable' => false,
'default' => '0',
'comment' => 'Vendor Is Allow Status']);
$setup->endSetup();
} } }
Step:2
app/code/Vendor/Ecommerce/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Ecommerce" setup_version="2.0.5">
<sequence><module name="Vendor_Ecommerce"/></sequence>
</module></config>
Step:3
After saving files, you need to run php bin/magento setup:upgrade
. Now check your database and you will be able to find a new custom table and new column in 'vendor_ecommerce' table.