'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('material_request', 'stores_reviewed_issue_at', {
      type: Sequelize.DATE,
      allowNull: true,
      comment: 'Stores refreshed stock for Materials-for-Issue list'
    });
    await queryInterface.addColumn('material_request', 'stores_reviewed_issue_by', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'user', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'SET NULL'
    });
    await queryInterface.addColumn('material_request', 'stores_reviewed_pr_at', {
      type: Sequelize.DATE,
      allowNull: true,
      comment: 'Stores refreshed stock for Materials-for-PR list'
    });
    await queryInterface.addColumn('material_request', 'stores_reviewed_pr_by', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'user', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'SET NULL'
    });
  },

  async down(queryInterface) {
    await queryInterface.removeColumn('material_request', 'stores_reviewed_pr_by');
    await queryInterface.removeColumn('material_request', 'stores_reviewed_pr_at');
    await queryInterface.removeColumn('material_request', 'stores_reviewed_issue_by');
    await queryInterface.removeColumn('material_request', 'stores_reviewed_issue_at');
  }
};
