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

primary_role: {
        type: DataTypes.ENUM,
      
      

        values: [

"student",


"career_changer",


"professional",


"job_seeker",


"founder",


"manager",


"other"

        ],

      },

goals_summary: {
        type: DataTypes.TEXT,
      
      

      },

focus_area: {
        type: DataTypes.TEXT,
      
      

      },

time_commitment: {
        type: DataTypes.TEXT,
      
      

      },

constraints_notes: {
        type: DataTypes.TEXT,
      
      

      },

ai_profile_draft: {
        type: DataTypes.TEXT,
      
      

      },

vision_statement: {
        type: DataTypes.TEXT,
      
      

      },

onboarding_completed_at: {
        type: DataTypes.DATE,
      
      

      },

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

      },

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

  private_profiles.associate = (db) => {

    db.private_profiles.belongsToMany(db.resume_documents, {
      as: 'resume_documents',
      foreignKey: {
        name: 'private_profiles_resume_documentsId',
      },
      constraints: false,
      through: 'private_profilesResume_documentsResume_documents',
    });

    db.private_profiles.belongsToMany(db.resume_documents, {
      as: 'resume_documents_filter',
      foreignKey: {
        name: 'private_profiles_resume_documentsId',
      },
      constraints: false,
      through: 'private_profilesResume_documentsResume_documents',
    });

    db.private_profiles.belongsToMany(db.coaching_sessions, {
      as: 'coaching_sessions',
      foreignKey: {
        name: 'private_profiles_coaching_sessionsId',
      },
      constraints: false,
      through: 'private_profilesCoaching_sessionsCoaching_sessions',
    });

    db.private_profiles.belongsToMany(db.coaching_sessions, {
      as: 'coaching_sessions_filter',
      foreignKey: {
        name: 'private_profiles_coaching_sessionsId',
      },
      constraints: false,
      through: 'private_profilesCoaching_sessionsCoaching_sessions',
    });


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




























//end loop



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




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

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



  return private_profiles;
};


