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

relationship_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"mother",


"father",


"guardian",


"other"

        ],

      },

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

      },

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

      },

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

      },

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

  student_parent_links.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.student_parent_links.belongsTo(db.students, {
      as: 'student',
      foreignKey: {
        name: 'studentId',
      },
      constraints: false,
    });

    db.student_parent_links.belongsTo(db.parents, {
      as: 'parent',
      foreignKey: {
        name: 'parentId',
      },
      constraints: false,
    });




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

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



  return student_parent_links;
};


