const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const world_calendar_days = sequelize.define(
    'world_calendar_days',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

day_start_at: {
        type: DataTypes.DATE,
      
      

      },

day_end_at: {
        type: DataTypes.DATE,
      
      

      },

season: {
        type: DataTypes.ENUM,
      
      

        values: [

"summer",


"autumn",


"winter",


"spring",


"wet",


"dry"

        ],

      },

tourism_index: {
        type: DataTypes.DECIMAL,
      
      

      },

inflation_index: {
        type: DataTypes.DECIMAL,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  world_calendar_days.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity




































    db.world_calendar_days.hasMany(db.price_modifiers, {
      as: 'price_modifiers_calendar_day',
      foreignKey: {
          name: 'calendar_dayId',
      },
      constraints: false,
    });
















//end loop



    db.world_calendar_days.belongsTo(db.weather_states, {
      as: 'weather_state',
      foreignKey: {
        name: 'weather_stateId',
      },
      constraints: false,
    });




    db.world_calendar_days.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.world_calendar_days.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return world_calendar_days;
};


