'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.removeIndex('production_nesting_confirmation', 'uq_pnc_po_thickness_grade');
    await queryInterface.addColumn('production_nesting_confirmation', 'sheet_material_selections', {
      type: Sequelize.TEXT('long'),
      allowNull: true
    });
    await queryInterface.addIndex(
      'production_nesting_confirmation',
      ['production_order_id', 'thickness', 'grade_short', 'max_length', 'max_width'],
      { unique: true, name: 'uq_pnc_po_thickness_grade_len_wid' }
    );
  },

  down: async (queryInterface) => {
    await queryInterface.removeIndex('production_nesting_confirmation', 'uq_pnc_po_thickness_grade_len_wid');
    await queryInterface.removeColumn('production_nesting_confirmation', 'sheet_material_selections');
    await queryInterface.addIndex(
      'production_nesting_confirmation',
      ['production_order_id', 'thickness', 'grade_short'],
      { unique: true, name: 'uq_pnc_po_thickness_grade' }
    );
  }
};
