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

name: {
        type: DataTypes.TEXT,

      },

status: {
        type: DataTypes.TEXT,

      },

quote_title: {
        type: DataTypes.TEXT,

      },

total_quoted: {
        type: DataTypes.DECIMAL,

      },

estimated_profit: {
        type: DataTypes.DECIMAL,

      },

created_date: {
        type: DataTypes.DATE,

      },

last_modified_date: {
        type: DataTypes.DATE,

      },

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

  quotes.associate = (db) => {

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

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

  return quotes;
};

