'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    const table = await queryInterface.describeTable('fg_dispatch');

    if (!Object.prototype.hasOwnProperty.call(table, 'delivery_status')) {
      await queryInterface.addColumn('fg_dispatch', 'delivery_status', {
        type: Sequelize.ENUM('NOT_DELIVERED', 'PARTIALLY_DELIVERED', 'FULLY_DELIVERED'),
        allowNull: false,
        defaultValue: 'NOT_DELIVERED'
      });
    }
  },

  async down(queryInterface) {
    const table = await queryInterface.describeTable('fg_dispatch');
    if (Object.prototype.hasOwnProperty.call(table, 'delivery_status')) {
      await queryInterface.removeColumn('fg_dispatch', 'delivery_status');
    }
  }
};

