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

reporting_week_start_at: {
        type: DataTypes.DATE,
      
      

      },

reporting_week_end_at: {
        type: DataTypes.DATE,
      
      

      },

overall_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"green",


"amber",


"red"

        ],

      },

accomplishments: {
        type: DataTypes.TEXT,
      
      

      },

next_steps: {
        type: DataTypes.TEXT,
      
      

      },

risks_issues: {
        type: DataTypes.TEXT,
      
      

      },

client_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  project_status_reports.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.project_status_reports.belongsTo(db.tenants, {
      as: 'tenant',
      foreignKey: {
        name: 'tenantId',
      },
      constraints: false,
    });

    db.project_status_reports.belongsTo(db.projects, {
      as: 'project',
      foreignKey: {
        name: 'projectId',
      },
      constraints: false,
    });

    db.project_status_reports.belongsTo(db.users, {
      as: 'author',
      foreignKey: {
        name: 'authorId',
      },
      constraints: false,
    });

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




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

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



  return project_status_reports;
};


