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

policy_name: {
        type: DataTypes.TEXT,
      
      

      },

scope: {
        type: DataTypes.ENUM,
      
      

        values: [

"free_user",


"member",


"admin",


"custom"

        ],

      },

daily_request_limit: {
        type: DataTypes.INTEGER,
      
      

      },

monthly_request_limit: {
        type: DataTypes.INTEGER,
      
      

      },

daily_cost_limit: {
        type: DataTypes.DECIMAL,
      
      

      },

monthly_cost_limit: {
        type: DataTypes.DECIMAL,
      
      

      },

hard_block_on_limit: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

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

  usage_limit_policies.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.usage_limit_policies.belongsTo(db.users, {
      as: 'createdBy',
    });

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



  return usage_limit_policies;
};


