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

resume_text: {
        type: DataTypes.TEXT,
      
      

      },

current_role_text: {
        type: DataTypes.TEXT,
      
      

      },

target_role_text: {
        type: DataTypes.TEXT,
      
      

      },

clarifying_questions: {
        type: DataTypes.TEXT,
      
      

      },

career_path: {
        type: DataTypes.TEXT,
      
      

      },

skill_gaps: {
        type: DataTypes.TEXT,
      
      

      },

next_steps: {
        type: DataTypes.TEXT,
      
      

      },

resume_suggestions: {
        type: DataTypes.TEXT,
      
      

      },

visibility: {
        type: DataTypes.ENUM,
      
      

        values: [

"private",


"shareable_link"

        ],

      },

share_token: {
        type: DataTypes.TEXT,
      
      

      },

generated_at: {
        type: DataTypes.DATE,
      
      

      },

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

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

    db.career_coach_reports.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });



    db.career_coach_reports.hasMany(db.file, {
      as: 'resume_file',
      foreignKey: 'belongsToId',
      constraints: false,
      scope: {
        belongsTo: db.career_coach_reports.getTableName(),
        belongsToColumn: 'resume_file',
      },
    });


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

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



  return career_coach_reports;
};


