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

form_key: {
        type: DataTypes.TEXT,
      
      

      },

action: {
        type: DataTypes.ENUM,
      
      

        values: [

"create",


"edit",


"delete"

        ],

      },

severity: {
        type: DataTypes.ENUM,
      
      

        values: [

"info",


"warning",


"critical"

        ],

      },

message_template: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

  form_alarms.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.form_alarms.belongsTo(db.businesses, {
      as: 'business',
      foreignKey: {
        name: 'businessId',
      },
      constraints: false,
    });




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

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



  return form_alarms;
};


