'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.addColumn('job_logs', 'workersCompClassId', {
      type: Sequelize.UUID,
      references: {
        model: 'workers_comp_classes',
        key: 'id',
      },
    });
    // Remove the old enum column
    // The enum type might cause issues if we try to drop it directly without dropping dependent views,
    // but just dropping the column is usually fine.
    await queryInterface.removeColumn('job_logs', 'workers_comp_class');
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.removeColumn('job_logs', 'workersCompClassId');
    await queryInterface.addColumn('job_logs', 'workers_comp_class', {
      type: Sequelize.ENUM('roof', 'ladder', 'ground'),
    });
  },
};
