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

name: {
        type: DataTypes.TEXT,
      
      

      },

reward_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"reduction",


"ticket_tombola"

        ],

      },

points_to_value_rate: {
        type: DataTypes.DECIMAL,
      
      

      },

max_discount_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

starts_at: {
        type: DataTypes.DATE,
      
      

      },

ends_at: {
        type: DataTypes.DATE,
      
      

      },

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

      },

description: {
        type: DataTypes.TEXT,
      
      

      },

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

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

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



  return loyalty_rules;
};


