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

sequence_order: {
        type: DataTypes.INTEGER,
      
      

      },

speaker: {
        type: DataTypes.ENUM,
      
      

        values: [

"agent",


"customer",


"coach",


"system"

        ],

      },

step_text: {
        type: DataTypes.TEXT,
      
      

      },

expected_response_hint: {
        type: DataTypes.TEXT,
      
      

      },

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

  simulation_steps.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.simulation_steps.belongsTo(db.simulations, {
      as: 'simulation',
      foreignKey: {
        name: 'simulationId',
      },
      constraints: false,
    });

    db.simulation_steps.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return simulation_steps;
};


