'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('customer_po', 'order_number', {
      type: Sequelize.STRING(50),
      allowNull: true
    });

    await queryInterface.addIndex('customer_po', ['company_id', 'plant_id', 'fiscal_year_id', 'order_number'], {
      unique: true,
      name: 'unique_customer_po_order_number'
    });
  },

  async down(queryInterface) {
    await queryInterface.removeIndex('customer_po', 'unique_customer_po_order_number');
    await queryInterface.removeColumn('customer_po', 'order_number');
  }
};

