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

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"new",


"in_review",


"sent",


"replied",


"closed"

        ],

      },

subject: {
        type: DataTypes.TEXT,
      
      

      },

message: {
        type: DataTypes.TEXT,
      
      

      },

contact_email: {
        type: DataTypes.TEXT,
      
      

      },

sent_at: {
        type: DataTypes.DATE,
      
      

      },

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

  talent_inquiries.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.talent_inquiries.belongsTo(db.organizations, {
      as: 'organization',
      foreignKey: {
        name: 'organizationId',
      },
      constraints: false,
    });

    db.talent_inquiries.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });




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

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



  return talent_inquiries;
};


