'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    const table = 'route_card_operation';
    const cols = await queryInterface.describeTable(table);

    if (!cols.checked_qty) {
      await queryInterface.addColumn(table, 'checked_qty', {
        type: Sequelize.DECIMAL(18, 3),
        allowNull: false,
        defaultValue: 0,
        after: 'completed_qty'
      });
    }
  },

  async down(queryInterface) {
    const table = 'route_card_operation';
    const cols = await queryInterface.describeTable(table);
    if (cols.checked_qty) {
      await queryInterface.removeColumn(table, 'checked_qty');
    }
  }
};
