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

code: {
        type: DataTypes.TEXT,
      
      

      },

name: {
        type: DataTypes.TEXT,
      
      

      },

parent_code: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

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




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

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



  return warehouse_item_groups;
};


