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

name: {
        type: DataTypes.TEXT,
      
      

      },

partner_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"business_owner",


"supplier",


"distributor",


"strategic_partner",


"investor",


"advisor"

        ],

      },

website_url: {
        type: DataTypes.TEXT,
      
      

      },

contact_name: {
        type: DataTypes.TEXT,
      
      

      },

contact_email: {
        type: DataTypes.TEXT,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"researching",


"contacted",


"in_talks",


"declined",


"closed"

        ],

      },

last_contact_at: {
        type: DataTypes.DATE,
      
      

      },

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

  partner_targets.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.partner_targets.belongsTo(db.deal_packages, {
      as: 'deal_package',
      foreignKey: {
        name: 'deal_packageId',
      },
      constraints: false,
    });

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




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

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



  return partner_targets;
};


