'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    const table = await queryInterface.describeTable('receipt_entry');
    if (!Object.prototype.hasOwnProperty.call(table, 'bank_name')) {
      await queryInterface.addColumn('receipt_entry', 'bank_name', {
        type: Sequelize.STRING(120),
        allowNull: true
      });
    }
    if (!Object.prototype.hasOwnProperty.call(table, 'ifsc_code')) {
      await queryInterface.addColumn('receipt_entry', 'ifsc_code', {
        type: Sequelize.STRING(20),
        allowNull: true
      });
    }
  },

  async down(queryInterface) {
    const table = await queryInterface.describeTable('receipt_entry');
    if (Object.prototype.hasOwnProperty.call(table, 'ifsc_code')) {
      await queryInterface.removeColumn('receipt_entry', 'ifsc_code');
    }
    if (Object.prototype.hasOwnProperty.call(table, 'bank_name')) {
      await queryInterface.removeColumn('receipt_entry', 'bank_name');
    }
  }
};

