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

name: {
        type: DataTypes.TEXT,
      
      

      },

source: {
        type: DataTypes.ENUM,
      
      

        values: [

"STREAK",


"REFERRAL",


"PRODUCT_BONUS",


"ADMIN_ADJUSTMENT",


"OTHER"

        ],

      },

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

      },

base_doodlecoins: {
        type: DataTypes.INTEGER,
      
      

      },

multiplier: {
        type: DataTypes.DECIMAL,
      
      

      },

min_streak_days: {
        type: DataTypes.INTEGER,
      
      

      },

max_streak_days: {
        type: DataTypes.INTEGER,
      
      

      },

description: {
        type: DataTypes.TEXT,
      
      

      },

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

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

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



  return coin_earning_rules;
};


