<?php
namespace MagePal\TestDiscount\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){
$setup->startSetup();
if (version_compare($context->getVersion(), ‘1.0.2’) < 0||version_compare($context->getVersion(), ‘1.0.3’) < 0||version_compare($context->getVersion(), ‘1.0.4’) < 0
||version_compare($context->getVersion(), ‘1.0.5’) < 0
) {
// Get module table
$tableName = $setup->getTable(‘quote_address’);
// Check if the table already exists
if ($setup->getConnection()->isTableExists($tableName) == true) {
// Declare data
$columns = [
‘crewards_amount’ => [
‘type’ => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,
‘nullable’ => false,
‘length’=>’6,2’,
‘comment’ => ‘rewards amount’,
],
‘base_crewards_amount’ => [
‘type’ => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,
‘nullable’ => false,
‘length’=>’6,2’,
‘comment’ => ‘base rewards amount’,
]
];
$connection = $setup->getConnection();
foreach ($columns as $name => $definition) {
//$connection->modifyColumn($tableName, $name, $definition);
$connection->addColumn($tableName, $name, $definition);
}
}
}
$setup->endSetup();
}
}