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

name: {
        type: DataTypes.TEXT,
      
      

      },

base_url: {
        type: DataTypes.TEXT,
      
      

      },

provider_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"market_data",


"news",


"ai"

        ],

      },

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

      },

last_health_check_at: {
        type: DataTypes.DATE,
      
      

      },

health_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"unknown",


"ok",


"degraded",


"down"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  api_providers.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.api_providers.belongsTo(db.users, {
      as: 'createdBy',
    });

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



  return api_providers;
};


