'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('material', 'last_purchase_rate', {
      type: Sequelize.DECIMAL(18, 2),
      allowNull: true
    });
    await queryInterface.addColumn('material', 'last_purchase_date', {
      type: Sequelize.DATEONLY,
      allowNull: true
    });

    await queryInterface.addIndex('material', ['last_purchase_date'], { name: 'material_last_purchase_date_idx' });
  },

  async down(queryInterface) {
    await queryInterface.removeIndex('material', 'material_last_purchase_date_idx');
    await queryInterface.removeColumn('material', 'last_purchase_date');
    await queryInterface.removeColumn('material', 'last_purchase_rate');
  }
};
