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

name: {
        type: DataTypes.TEXT,
      
      

      },

reward_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"yux",


"box",


"cosmetic",


"title",


"badge"

        ],

      },

day_index: {
        type: DataTypes.INTEGER,
      
      

      },

yux_amount: {
        type: DataTypes.INTEGER,
      
      

      },

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

      },

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

  daily_rewards.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.daily_rewards.belongsTo(db.boxes, {
      as: 'box',
      foreignKey: {
        name: 'boxId',
      },
      constraints: false,
    });

    db.daily_rewards.belongsTo(db.cosmetics, {
      as: 'cosmetic',
      foreignKey: {
        name: 'cosmeticId',
      },
      constraints: false,
    });

    db.daily_rewards.belongsTo(db.titles, {
      as: 'title_item',
      foreignKey: {
        name: 'title_itemId',
      },
      constraints: false,
    });

    db.daily_rewards.belongsTo(db.badges, {
      as: 'badge',
      foreignKey: {
        name: 'badgeId',
      },
      constraints: false,
    });




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

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



  return daily_rewards;
};


