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

activated_at: {
        type: DataTypes.DATE,
      
      

      },

activated_by: {
        type: DataTypes.TEXT,
      
      

      },

client_info: {
        type: DataTypes.TEXT,
      
      

      },

activation_token: {
        type: DataTypes.TEXT,
      
      

      },

result: {
        type: DataTypes.ENUM,
      
      

        values: [

"success",


"failed"

        ],

      },

failure_reason: {
        type: DataTypes.TEXT,
      
      

      },

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

  license_activations.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.license_activations.belongsTo(db.license_keys, {
      as: 'license_key',
      foreignKey: {
        name: 'license_keyId',
      },
      constraints: false,
    });




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

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



  return license_activations;
};


