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

finish_rank: {
        type: DataTypes.INTEGER,
      
      

      },

bonus_points: {
        type: DataTypes.INTEGER,
      
      

      },

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

  league_finish_awards.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.league_finish_awards.belongsTo(db.leagues, {
      as: 'league',
      foreignKey: {
        name: 'leagueId',
      },
      constraints: false,
    });

    db.league_finish_awards.belongsTo(db.players, {
      as: 'player',
      foreignKey: {
        name: 'playerId',
      },
      constraints: false,
    });

    db.league_finish_awards.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return league_finish_awards;
};


