"use strict";

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction(t => {
      return Promise.all([
        queryInterface.removeColumn("MarketAlerts", "olxUrl", {
          transaction: t
        }),
        queryInterface.addColumn(
          "MarketAlerts",
          "url",
          {
            type: Sequelize.STRING
          },
          { transaction: t }
        ),
        queryInterface.addColumn(
          "MarketAlerts",
          "realestateOrigin",
          {
            type: Sequelize.STRING
          },
          { transaction: t }
        ),
        queryInterface.addColumn(
          "MarketAlerts",
          "originId",
          {
            type: Sequelize.STRING
          },
          { transaction: t }
        )
      ]);
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction(t => {
      return Promise.all([
        queryInterface.removeColumn("MarketAlerts", "url", { transaction: t }),
        queryInterface.removeColumn("MarketAlerts", "realestateOrigin", {
          transaction: t
        }),
        queryInterface.removeColumn("MarketAlerts", "originId", {
          transaction: t
        }),
        queryInterface.addColumn(
          "MarketAlerts",
          "olxUrl",
          {
            type: Sequelize.STRING
          },
          { transaction: t }
        )
      ]);
    });
  }
};
