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

session_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"one_on_one",


"qa_review",


"performance_review",


"training_followup"

        ],

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"scheduled",


"completed",


"cancelled",


"needs_followup"

        ],

      },

scheduled_at: {
        type: DataTypes.DATE,
      
      

      },

completed_at: {
        type: DataTypes.DATE,
      
      

      },

agenda: {
        type: DataTypes.TEXT,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

action_items: {
        type: DataTypes.TEXT,
      
      

      },

follow_up_at: {
        type: DataTypes.DATE,
      
      

      },

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

  coaching_sessions.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.coaching_sessions.belongsTo(db.organizations, {
      as: 'organization',
      foreignKey: {
        name: 'organizationId',
      },
      constraints: false,
    });

    db.coaching_sessions.belongsTo(db.users, {
      as: 'coach',
      foreignKey: {
        name: 'coachId',
      },
      constraints: false,
    });

    db.coaching_sessions.belongsTo(db.users, {
      as: 'coachee',
      foreignKey: {
        name: 'coacheeId',
      },
      constraints: false,
    });




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

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



  return coaching_sessions;
};


