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

assessment_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"refresher",


"diagnostic",


"post_training"

        ],

      },

assessed_at: {
        type: DataTypes.DATE,
      
      

      },

overall_score: {
        type: DataTypes.DECIMAL,
      
      

      },

insights_summary: {
        type: DataTypes.TEXT,
      
      

      },

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

  knowledge_gap_assessments.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.knowledge_gap_assessments.belongsTo(db.organizations, {
      as: 'organization',
      foreignKey: {
        name: 'organizationId',
      },
      constraints: false,
    });

    db.knowledge_gap_assessments.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });




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

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



  return knowledge_gap_assessments;
};


