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

action: {
        type: DataTypes.ENUM,
      
      

        values: [

"verification_approved",


"verification_rejected",


"verification_requested_more_docs",


"booking_force_release",


"booking_refund",


"dispute_resolved",


"user_suspended",


"user_banned",


"user_warned",


"password_reset",


"config_updated",


"impersonation_started",


"impersonation_ended",


"content_removed",


"content_kept"

        ],

      },

target_entity: {
        type: DataTypes.TEXT,
      
      

      },

target_id: {
        type: DataTypes.TEXT,
      
      

      },

details: {
        type: DataTypes.TEXT,
      
      

      },

occurred_at: {
        type: DataTypes.DATE,
      
      

      },

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

  admin_audit_logs.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.admin_audit_logs.belongsTo(db.users, {
      as: 'admin_user',
      foreignKey: {
        name: 'admin_userId',
      },
      constraints: false,
    });




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

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



  return admin_audit_logs;
};


