"use strict";
const { ACCESS_ROAD_TYPE, HEATING_TYPE } = require("../common/enums");

module.exports = {
  up: (queryInterface, Sequelize) => {
    return Promise.all([
      queryInterface.addColumn("SearchRequests", "includeIncompleteAds", {
        type: Sequelize.BOOLEAN
      }),
      queryInterface.addColumn("SearchRequests", "balcony", {
        type: Sequelize.BOOLEAN
      }),
      queryInterface.addColumn("SearchRequests", "newBuilding", {
        type: Sequelize.BOOLEAN
      }),
      queryInterface.addColumn("SearchRequests", "elevator", {
        type: Sequelize.BOOLEAN
      }),
      queryInterface.addColumn("SearchRequests", "numberOfRoomsMin", {
        type: Sequelize.REAL
      }),
      queryInterface.addColumn("SearchRequests", "numberOfRoomsMax", {
        type: Sequelize.REAL
      }),
      queryInterface.addColumn("SearchRequests", "numberOfFloorsMin", {
        type: Sequelize.INTEGER
      }),
      queryInterface.addColumn("SearchRequests", "numberOfFloorsMax", {
        type: Sequelize.INTEGER
      }),
      queryInterface.addColumn("SearchRequests", "floorMin", {
        type: Sequelize.INTEGER
      }),
      queryInterface.addColumn("SearchRequests", "floorMax", {
        type: Sequelize.INTEGER
      }),
      queryInterface.addColumn("SearchRequests", "accessRoadType", {
        type: Sequelize.TEXT,
        defaultValue: ACCESS_ROAD_TYPE.ANY.id
      }),
      queryInterface.addColumn("SearchRequests", "heatingType", {
        type: Sequelize.TEXT,
        defaultValue: HEATING_TYPE.ANY.id
      })
    ]);
  },

  down: (queryInterface, Sequelize) => {
    return Promise.all([
      queryInterface.removeColumn("SearchRequests", "includeIncompleteAds"),
      queryInterface.removeColumn("SearchRequests", "balcony"),
      queryInterface.removeColumn("SearchRequests", "newBuilding"),
      queryInterface.removeColumn("SearchRequests", "elevator"),
      queryInterface.removeColumn("SearchRequests", "numberOfRoomsMin"),
      queryInterface.removeColumn("SearchRequests", "numberOfRoomsMax"),
      queryInterface.removeColumn("SearchRequests", "numberOfFloorsMin"),
      queryInterface.removeColumn("SearchRequests", "numberOfFloorsMax"),
      queryInterface.removeColumn("SearchRequests", "floorMin"),
      queryInterface.removeColumn("SearchRequests", "floorMax"),
      queryInterface.removeColumn("SearchRequests", "accessRoadType"),
      queryInterface.removeColumn("SearchRequests", "heatingType")
    ]);
  }
};
