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

assignment_role: {
        type: DataTypes.ENUM,
      
      

        values: [

"teacher",


"counselor",


"shift_lead",


"driver",


"volunteer"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  staff_assignments.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.staff_assignments.belongsTo(db.users, {
      as: 'staff_user',
      foreignKey: {
        name: 'staff_userId',
      },
      constraints: false,
    });

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

    db.staff_assignments.belongsTo(db.age_groups, {
      as: 'age_group',
      foreignKey: {
        name: 'age_groupId',
      },
      constraints: false,
    });

    db.staff_assignments.belongsTo(db.curriculum_subjects, {
      as: 'subject',
      foreignKey: {
        name: 'subjectId',
      },
      constraints: false,
    });




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

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



  return staff_assignments;
};


