'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('subcontract_dc', 'customer_po_id', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'customer_po', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'SET NULL'
    });

    await queryInterface.addIndex('subcontract_dc', ['customer_po_id'], {
      name: 'subcontract_dc_customer_po_idx'
    });
  },

  async down(queryInterface) {
    await queryInterface.removeIndex('subcontract_dc', 'subcontract_dc_customer_po_idx');
    await queryInterface.removeColumn('subcontract_dc', 'customer_po_id');
  }
};
