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

name: {
        type: DataTypes.TEXT,
      
      

      },

trip_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"state_aim",


"national_aim"

        ],

      },

destination: {
        type: DataTypes.TEXT,
      
      

      },

start_datetime: {
        type: DataTypes.DATE,
      
      

      },

end_datetime: {
        type: DataTypes.DATE,
      
      

      },

package_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

  special_trips.associate = (db) => {


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




























//end loop



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




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

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



  return special_trips;
};


