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

trigger_question_index: {
        type: DataTypes.INTEGER,
      
      

      },

reward_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"bonus_points",


"double_points",


"triple_points",


"bonus_yux",


"mystery_prize",


"lucky_multiplier",


"jackpot"

        ],

      },

multiplier_value: {
        type: DataTypes.DECIMAL,
      
      

      },

bonus_points: {
        type: DataTypes.INTEGER,
      
      

      },

bonus_yux: {
        type: DataTypes.INTEGER,
      
      

      },

music_track: {
        type: DataTypes.ENUM,
      
      

        values: [

"track_a",


"track_b"

        ],

      },

event_started_at: {
        type: DataTypes.DATE,
      
      

      },

event_ended_at: {
        type: DataTypes.DATE,
      
      

      },

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

  wheel_events.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.wheel_events.belongsTo(db.matches, {
      as: 'match',
      foreignKey: {
        name: 'matchId',
      },
      constraints: false,
    });




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

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



  return wheel_events;
};


