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

name: {
        type: DataTypes.TEXT,
      
      

      },

program_shift: {
        type: DataTypes.ENUM,
      
      

        values: [

"day_camp",


"third_shift"

        ],

      },

block_start_datetime: {
        type: DataTypes.DATE,
      
      

      },

block_end_datetime: {
        type: DataTypes.DATE,
      
      

      },

block_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"meal",


"devotion",


"academics",


"arts_skills_rotation",


"recreation",


"bible_study",


"leadership_lab",


"quiet_time",


"pickup_dropoff"

        ],

      },

details: {
        type: DataTypes.TEXT,
      
      

      },

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

  activity_blocks.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.activity_blocks.belongsTo(db.age_groups, {
      as: 'age_group',
      foreignKey: {
        name: 'age_groupId',
      },
      constraints: false,
    });

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




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

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



  return activity_blocks;
};


