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

name: {
        type: DataTypes.TEXT,
      
      

      },

persona: {
        type: DataTypes.TEXT,
      
      

      },

system_prompt: {
        type: DataTypes.TEXT,
      
      

      },

tone: {
        type: DataTypes.ENUM,
      
      

        values: [

"friendly",


"strict",


"socratic",


"concise",


"detailed"

        ],

      },

supported_subjects: {
        type: DataTypes.TEXT,
      
      

      },

visibility: {
        type: DataTypes.ENUM,
      
      

        values: [

"public",


"private",


"organization"

        ],

      },

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

      },

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

  ai_mentor_profiles.associate = (db) => {


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



















    db.ai_mentor_profiles.hasMany(db.mentor_conversations, {
      as: 'mentor_conversations_mentor_profile',
      foreignKey: {
          name: 'mentor_profileId',
      },
      constraints: false,
    });














//end loop



    db.ai_mentor_profiles.belongsTo(db.organizations, {
      as: 'organization',
      foreignKey: {
        name: 'organizationId',
      },
      constraints: false,
    });



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


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

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



  return ai_mentor_profiles;
};


