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

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"required",


"signed",


"declined"

        ],

      },

signed_datetime: {
        type: DataTypes.DATE,
      
      

      },

signature_name: {
        type: DataTypes.TEXT,
      
      

      },

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

  document_signatures.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.document_signatures.belongsTo(db.waiver_documents, {
      as: 'waiver_document',
      foreignKey: {
        name: 'waiver_documentId',
      },
      constraints: false,
    });

    db.document_signatures.belongsTo(db.enrollments, {
      as: 'enrollment',
      foreignKey: {
        name: 'enrollmentId',
      },
      constraints: false,
    });

    db.document_signatures.belongsTo(db.guardians, {
      as: 'guardian',
      foreignKey: {
        name: 'guardianId',
      },
      constraints: false,
    });




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

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



  return document_signatures;
};


