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

full_name: {
        type: DataTypes.TEXT,

      },

sex: {
        type: DataTypes.ENUM,

        values: [

"M",

"F"

        ],

      },

date_of_birth: {
        type: DataTypes.DATE,

      },

document_type: {
        type: DataTypes.TEXT,

      },

document_number: {
        type: DataTypes.TEXT,

      },

phone_number: {
        type: DataTypes.TEXT,

      },

full_address_input: {
        type: DataTypes.TEXT,

      },

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

  guarantor.associate = (db) => {

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

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

  return guarantor;
};

