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 end_of_summer_trip_options = sequelize.define(
    'end_of_summer_trip_options',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

name: {
        type: DataTypes.TEXT,
      
      

      },

option_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"day_trip",


"overnight"

        ],

      },

destination: {
        type: DataTypes.TEXT,
      
      

      },

estimated_price: {
        type: DataTypes.DECIMAL,
      
      

      },

is_active: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

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

  end_of_summer_trip_options.associate = (db) => {


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






















    db.end_of_summer_trip_options.hasMany(db.end_of_summer_trip_selections, {
      as: 'end_of_summer_trip_selections_trip_option',
      foreignKey: {
          name: 'trip_optionId',
      },
      constraints: false,
    });







//end loop



    db.end_of_summer_trip_options.belongsTo(db.camp_sessions, {
      as: 'camp_session',
      foreignKey: {
        name: 'camp_sessionId',
      },
      constraints: false,
    });




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

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



  return end_of_summer_trip_options;
};


