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

profile_name: {
        type: DataTypes.TEXT,
      
      

      },

voice_description: {
        type: DataTypes.TEXT,
      
      

      },

do_say_examples: {
        type: DataTypes.TEXT,
      
      

      },

dont_say_examples: {
        type: DataTypes.TEXT,
      
      

      },

english_variant: {
        type: DataTypes.ENUM,
      
      

        values: [

"en_au",


"en_us",


"en_uk"

        ],

      },

reading_level_target: {
        type: DataTypes.INTEGER,
      
      

      },

formality_level: {
        type: DataTypes.DECIMAL,
      
      

      },

empathy_level: {
        type: DataTypes.DECIMAL,
      
      

      },

energy_level: {
        type: DataTypes.DECIMAL,
      
      

      },

humor_level: {
        type: DataTypes.DECIMAL,
      
      

      },

risk_tolerance: {
        type: DataTypes.DECIMAL,
      
      

      },

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

      },

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

      },

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

  brand_voice_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.brand_voice_profiles.hasMany(db.ad_projects, {
      as: 'ad_projects_brand_voice_profile',
      foreignKey: {
          name: 'brand_voice_profileId',
      },
      constraints: false,
    });













//end loop



    db.brand_voice_profiles.belongsTo(db.brands, {
      as: 'brand',
      foreignKey: {
        name: 'brandId',
      },
      constraints: false,
    });




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

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



  return brand_voice_profiles;
};


