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

session_name: {
        type: DataTypes.TEXT,
      
      

      },

prompt_context: {
        type: DataTypes.TEXT,
      
      

      },

white_hat_notes: {
        type: DataTypes.TEXT,
      
      

      },

red_hat_notes: {
        type: DataTypes.TEXT,
      
      

      },

black_hat_notes: {
        type: DataTypes.TEXT,
      
      

      },

yellow_hat_notes: {
        type: DataTypes.TEXT,
      
      

      },

green_hat_notes: {
        type: DataTypes.TEXT,
      
      

      },

blue_hat_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  six_hat_sessions.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.six_hat_sessions.belongsTo(db.campaigns, {
      as: 'campaign',
      foreignKey: {
        name: 'campaignId',
      },
      constraints: false,
    });

    db.six_hat_sessions.belongsTo(db.ad_projects, {
      as: 'ad_project',
      foreignKey: {
        name: 'ad_projectId',
      },
      constraints: false,
    });




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

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



  return six_hat_sessions;
};


