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

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"pending",


"tested",


"passed",


"failed",


"waived"

        ],

      },

tested_at: {
        type: DataTypes.DATE,
      
      

      },

evidence_reference: {
        type: DataTypes.TEXT,
      
      

      },

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

  notification_record_items.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.notification_record_items.belongsTo(db.notification_records, {
      as: 'notification_record',
      foreignKey: {
        name: 'notification_recordId',
      },
      constraints: false,
    });

    db.notification_record_items.belongsTo(db.authentication_methods, {
      as: 'authentication_method',
      foreignKey: {
        name: 'authentication_methodId',
      },
      constraints: false,
    });

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




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

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



  return notification_record_items;
};


