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

direction: {
        type: DataTypes.ENUM,
      
      

        values: [

"up",


"down"

        ],

      },

voted_at: {
        type: DataTypes.DATE,
      
      

      },

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

  seed_votes.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.seed_votes.belongsTo(db.clubs, {
      as: 'club',
      foreignKey: {
        name: 'clubId',
      },
      constraints: false,
    });

    db.seed_votes.belongsTo(db.users, {
      as: 'voter_user',
      foreignKey: {
        name: 'voter_userId',
      },
      constraints: false,
    });

    db.seed_votes.belongsTo(db.players, {
      as: 'target_player',
      foreignKey: {
        name: 'target_playerId',
      },
      constraints: false,
    });

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




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

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



  return seed_votes;
};


