'use strict';

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

    await queryInterface.addIndex('route_card_operation', ['operator_id'], {
      name: 'idx_rc_op_operator',
    });
  },

  async down(queryInterface) {
    await queryInterface.removeIndex('route_card_operation', 'idx_rc_op_operator');
    await queryInterface.removeColumn('route_card_operation', 'operator_id');
  },
};

