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

seed_score_snapshot: {
        type: DataTypes.INTEGER,
      
      

      },

sort_order: {
        type: DataTypes.INTEGER,
      
      

      },

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

  game_team_assignments.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.game_team_assignments.belongsTo(db.game_teams, {
      as: 'game_team',
      foreignKey: {
        name: 'game_teamId',
      },
      constraints: false,
    });

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

    db.game_team_assignments.belongsTo(db.game_guests, {
      as: 'guest',
      foreignKey: {
        name: 'guestId',
      },
      constraints: false,
    });

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




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

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



  return game_team_assignments;
};


