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

brand_name: {
        type: DataTypes.TEXT,
      
      

      },

footer_tagline: {
        type: DataTypes.TEXT,
      
      

      },

primary_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

secondary_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

accent_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

default_meta_title: {
        type: DataTypes.TEXT,
      
      

      },

default_meta_description: {
        type: DataTypes.TEXT,
      
      

      },

default_meta_keywords: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

  site_settings.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.site_settings.hasMany(db.file, {
      as: 'logo_images',
      foreignKey: 'belongsToId',
      constraints: false,
      scope: {
        belongsTo: db.site_settings.getTableName(),
        belongsToColumn: 'logo_images',
      },
    });


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

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



  return site_settings;
};


