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

type: {
        type: DataTypes.ENUM,
      
      

        values: [

"ID_CARD",


"PASSPORT",


"DRIVING_LICENSE",


"CPC_CODE95",


"ADR",


"MEDICAL",


"PSYCH",


"TACHO_CARD",


"WORK_CONTRACT",


"BANK_DETAILS",


"INCIDENT_REPORT",


"OTHER"

        ],

      },

keep_min_versions: {
        type: DataTypes.INTEGER,
      
      

      },

keep_files_days: {
        type: DataTypes.INTEGER,
      
      

      },

keep_version_days: {
        type: DataTypes.INTEGER,
      
      

      },

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

      },

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

  document_retention_policies.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_retention_policies.belongsTo(db.companies, {
      as: 'company',
      foreignKey: {
        name: 'companyId',
      },
      constraints: false,
    });




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

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



  return document_retention_policies;
};


