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

name: {
        type: DataTypes.TEXT,
      
      

      },

tier: {
        type: DataTypes.ENUM,
      
      

        values: [

"premium",


"premium_plus"

        ],

      },

price_monthly: {
        type: DataTypes.DECIMAL,
      
      

      },

price_yearly: {
        type: DataTypes.DECIMAL,
      
      

      },

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

      },

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

      },

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

      },

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

      },

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

      },

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

      },

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

      },

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

      },

description: {
        type: DataTypes.TEXT,
      
      

      },

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

  premium_plans.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity






















    db.premium_plans.hasMany(db.subscriptions, {
      as: 'subscriptions_plan',
      foreignKey: {
          name: 'planId',
      },
      constraints: false,
    });







//end loop






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

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



  return premium_plans;
};


