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

step_number: {
        type: DataTypes.INTEGER,
      
      

      },

step_title: {
        type: DataTypes.TEXT,
      
      

      },

step_description: {
        type: DataTypes.TEXT,
      
      

      },

icon_name: {
        type: DataTypes.TEXT,
      
      

      },

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

  process_steps.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.process_steps.belongsTo(db.quality_processes, {
      as: 'quality_process',
      foreignKey: {
        name: 'quality_processId',
      },
      constraints: false,
    });




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

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



  return process_steps;
};


