'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.removeColumn('general_receipt_item', 'uom_id');
    await queryInterface.removeColumn('general_receipt_item', 'material_id');
    await queryInterface.removeColumn('general_receipt_item', 'description');

    await queryInterface.removeColumn('general_dc_item', 'uom_id');
    await queryInterface.removeColumn('general_dc_item', 'material_id');
    await queryInterface.removeColumn('general_dc_item', 'description');
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.addColumn('general_dc_item', 'material_id', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'material', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'RESTRICT'
    });
    await queryInterface.addColumn('general_dc_item', 'description', {
      type: Sequelize.STRING(500),
      allowNull: true
    });
    await queryInterface.addColumn('general_dc_item', 'uom_id', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'uom', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'RESTRICT'
    });

    await queryInterface.addColumn('general_receipt_item', 'material_id', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'material', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'RESTRICT'
    });
    await queryInterface.addColumn('general_receipt_item', 'description', {
      type: Sequelize.STRING(500),
      allowNull: true
    });
    await queryInterface.addColumn('general_receipt_item', 'uom_id', {
      type: Sequelize.INTEGER,
      allowNull: true,
      references: { model: 'uom', key: 'id' },
      onUpdate: 'CASCADE',
      onDelete: 'RESTRICT'
    });
  }
};
