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

code: {
        type: DataTypes.TEXT,
      
      

      },

description: {
        type: DataTypes.TEXT,
      
      

      },

discount_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"percentage",


"fixed_amount",


"free_shipping"

        ],

      },

value_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

minimum_order_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

usage_limit: {
        type: DataTypes.INTEGER,
      
      

      },

usage_count: {
        type: DataTypes.INTEGER,
      
      

      },

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

      },

starts_at: {
        type: DataTypes.DATE,
      
      

      },

ends_at: {
        type: DataTypes.DATE,
      
      

      },

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

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

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



  return discount_codes;
};


