'use strict';

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

    if (!cols.rework_qty) {
      await queryInterface.addColumn(table, 'rework_qty', {
        type: Sequelize.DECIMAL(18, 3),
        allowNull: false,
        defaultValue: 0,
        after: 'rejected_qty',
        comment: 'Rework quantity',
      });
    }
  },

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

