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

role_name: {
        type: DataTypes.ENUM,
      
      

        values: [

"judge",


"plaintiff",


"defendant",


"petitioner",


"respondent",


"opposing_counsel",


"witness",


"clerk",


"bailiff"

        ],

      },

actor_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"user",


"ai"

        ],

      },

display_name: {
        type: DataTypes.TEXT,
      
      

      },

instructions: {
        type: DataTypes.TEXT,
      
      

      },

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

  mock_trial_roles.associate = (db) => {


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
























    db.mock_trial_roles.hasMany(db.mock_trial_turns, {
      as: 'mock_trial_turns_role',
      foreignKey: {
          name: 'roleId',
      },
      constraints: false,
    });








//end loop



    db.mock_trial_roles.belongsTo(db.mock_trials, {
      as: 'mock_trial',
      foreignKey: {
        name: 'mock_trialId',
      },
      constraints: false,
    });




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

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



  return mock_trial_roles;
};


