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

service_name: {
        type: DataTypes.TEXT,
      
      

      },

min_price: {
        type: DataTypes.DECIMAL,
      
      

      },

max_price: {
        type: DataTypes.DECIMAL,
      
      

      },

typical_price: {
        type: DataTypes.DECIMAL,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

created_at_ts: {
        type: DataTypes.DATE,
      
      

      },

updated_at_ts: {
        type: DataTypes.DATE,
      
      

      },

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

  service_prices.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.service_prices.belongsTo(db.businesses, {
      as: 'business',
      foreignKey: {
        name: 'businessId',
      },
      constraints: false,
    });




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

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



  return service_prices;
};


