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

scenario_name: {
        type: DataTypes.TEXT,
      
      

      },

scenario_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"mock_campaign",


"mock_client_call",


"policy_stress_test",


"competitor_teardown",


"compliance_drill",


"prompt_regression"

        ],

      },

scenario_description: {
        type: DataTypes.TEXT,
      
      

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"draft",


"running",


"completed",


"approved",


"rejected"

        ],

      },

last_run_at: {
        type: DataTypes.DATE,
      
      

      },

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

  sandbox_scenarios.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.sandbox_scenarios.belongsTo(db.campaign_brain_configs, {
      as: 'campaign_brain_config',
      foreignKey: {
        name: 'campaign_brain_configId',
      },
      constraints: false,
    });

    db.sandbox_scenarios.belongsTo(db.safety_policies, {
      as: 'safety_policy',
      foreignKey: {
        name: 'safety_policyId',
      },
      constraints: false,
    });




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

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



  return sandbox_scenarios;
};


