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

category: {
        type: DataTypes.ENUM,
      
      

        values: [

"story",


"document",


"comment",


"approval",


"sprint",


"blocker"

        ],

      },

summary: {
        type: DataTypes.TEXT,
      
      

      },

link_path: {
        type: DataTypes.TEXT,
      
      

      },

happened_at: {
        type: DataTypes.DATE,
      
      

      },

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

  activity_feed_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.activity_feed_items.belongsTo(db.teams, {
      as: 'team',
      foreignKey: {
        name: 'teamId',
      },
      constraints: false,
    });

    db.activity_feed_items.belongsTo(db.users, {
      as: 'actor',
      foreignKey: {
        name: 'actorId',
      },
      constraints: false,
    });

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




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

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



  return activity_feed_items;
};


