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

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

      },

effective_start: {
        type: DataTypes.DATE,
      
      

      },

effective_end: {
        type: DataTypes.DATE,
      
      

      },

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

  employee_pay_types.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.employee_pay_types.belongsTo(db.users, {
      as: 'employee',
      foreignKey: {
        name: 'employeeId',
      },
      constraints: false,
    });

    db.employee_pay_types.belongsTo(db.pay_types, {
      as: 'pay_type',
      foreignKey: {
        name: 'pay_typeId',
      },
      constraints: false,
    });




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

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



  return employee_pay_types;
};


