'use strict';

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

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

  async down(queryInterface) {
    await queryInterface.removeIndex('route_card_operation', 'idx_rc_op_department');
    await queryInterface.removeColumn('route_card_operation', 'department_id');
  },
};

