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

row_number: {
        type: DataTypes.INTEGER,
      
      

      },

raw_row_json: {
        type: DataTypes.TEXT,
      
      

      },

error_message: {
        type: DataTypes.TEXT,
      
      

      },

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

  csv_import_row_errors.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.csv_import_row_errors.belongsTo(db.csv_import_jobs, {
      as: 'csv_import_job',
      foreignKey: {
        name: 'csv_import_jobId',
      },
      constraints: false,
    });




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

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



  return csv_import_row_errors;
};


