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

block_name: {
        type: DataTypes.TEXT,
      
      

      },

start_date: {
        type: DataTypes.DATE,
      
      

      },

end_date: {
        type: DataTypes.DATE,
      
      

      },

focus: {
        type: DataTypes.ENUM,
      
      

        values: [

"strength",


"hypertrophy",


"endurance",


"fat_loss",


"skill",


"deload",


"rehab",


"mixed"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  training_blocks.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.training_blocks.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });




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

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



  return training_blocks;
};


