"use strict";

module.exports = {
  up: (queryInterface, Sequelize) => {
    const tableFields = {
      id: {
        type: Sequelize.BIGINT,
        autoIncrement: true,
        allowNull: false,
        primaryKey: true
      },
      url: {
        type: Sequelize.TEXT,
        allowNull: false
      },
      agencyObjectId: {
        type: Sequelize.TEXT,
        allowNull: false
      },
      originAgencyName: {
        type: Sequelize.TEXT,
        allowNull: false
      },
      realEstateType: {
        type: Sequelize.TEXT,
        allowNull: false
      },
      adType: {
        type: Sequelize.TEXT,
        allowNull: false
      },
      price: Sequelize.REAL,
      area: Sequelize.REAL,
      gardenSize: Sequelize.REAL,
      streetNumber: Sequelize.INTEGER,
      streetName: Sequelize.TEXT,
      locality: Sequelize.TEXT,
      municipality: Sequelize.TEXT,
      city: Sequelize.TEXT,
      region: Sequelize.TEXT,
      entity: Sequelize.TEXT,
      country: Sequelize.TEXT,
      locationLat: Sequelize.REAL,
      locationLong: Sequelize.REAL,
      lastTimeCrawled: {
        type: Sequelize.DATE,
        allowNull: false
      },
      deleted: {
        type: Sequelize.BOOLEAN,
        allowNull: false
      },
      sold: {
        type: Sequelize.BOOLEAN,
        allowNull: false
      },
      createdAt: {
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal("NOW()")
      },
      updatedAt: {
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal("NOW()")
      }
    };
    return queryInterface.createTable("RealEstates", tableFields);
  },

  down: queryInterface => {
    return queryInterface.dropTable("RealEstates", {});
  }
};
