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

profile_name: {
        type: DataTypes.TEXT,
      
      

      },

profile_category: {
        type: DataTypes.ENUM,
      
      

        values: [

"domain_expert",


"growth",


"copywriting",


"analysis",


"compliance",


"strategy",


"creative",


"custom"

        ],

      },

goal_statement: {
        type: DataTypes.TEXT,
      
      

      },

behavior_rules: {
        type: DataTypes.TEXT,
      
      

      },

preferred_sources_description: {
        type: DataTypes.TEXT,
      
      

      },

citation_strictness: {
        type: DataTypes.DECIMAL,
      
      

      },

creativity_level: {
        type: DataTypes.DECIMAL,
      
      

      },

compliance_strictness: {
        type: DataTypes.DECIMAL,
      
      

      },

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

      },

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

  brain_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.brain_profiles.hasMany(db.campaign_brain_configs, {
      as: 'campaign_brain_configs_brain_profile',
      foreignKey: {
          name: 'brain_profileId',
      },
      constraints: false,
    });
















//end loop






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

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



  return brain_profiles;
};


