<?php
namespace Magento\Billdesk\Setup;

use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\DB\Ddl\Table;

// use Magento\Framework\Setup\InstallSchemaInterface;
// use Magento\Framework\Setup\ModuleContextInterface;
// use Magento\Framework\Setup\SchemaSetupInterface;
// use Magento\Setup\Exception;

class UpgradeSchema implements UpgradeSchemaInterface
{
	public function upgrade( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
		$installer = $setup;
		$installer->startSetup();
		if (!$installer->tableExists('billdesk_payment_transation')) {
			$table = $installer->getConnection()->newTable(
				$installer->getTable('billdesk_payment_transation')
            )->addColumn(
                'order_id',
                Table::TYPE_INTEGER,
                null,
                ['identity' => true, 'nullable' => false, 'primary'  => true, 'unsigned' => true],
                'order_id'
            )->addColumn(
                'orderid',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'orderid'
            )->addColumn(
                'transactionid',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'transactionid'
            )->addColumn(
                'transaction_error_type',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'transaction_error_type'
            )->addColumn(
                'payment_method_type',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'payment_method_type'
            )->addColumn(
                'transaction_date',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'transaction_date'
            )->addColumn(
                'transaction_error_code',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'transaction_error_code'
            )->addColumn(
                'currency',
                Table::TYPE_INTEGER,
                null,
                ['nullable => false'],
                'currency'
            )->addColumn(
                'auth_status',
                Table::TYPE_INTEGER,
                null,
                ['nullable => false'],
                'auth_status'
            )->addColumn(
                'transaction_error_desc',
                Table::TYPE_TEXT,
                null,
                ['nullable => false'],
                'transaction_error_desc'
            )->addColumn(
                'charge_amount',
                Table::TYPE_DECIMAL,
                '10,2',
                ['nullable => false'],
                'charge_amount'
            )->setOption('charset', 'utf8');
			$installer->getConnection()->createTable($table);
		}
		$installer->endSetup();
    }
}
