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

name: {
        type: DataTypes.TEXT,

      },

created_by: {
        type: DataTypes.TEXT,

      },

created_date: {
        type: DataTypes.DATE,

      },

last_modified_by: {
        type: DataTypes.TEXT,

      },

last_modified_date: {
        type: DataTypes.DATE,

      },

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

  adbuilder_templates.associate = (db) => {

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

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

  return adbuilder_templates;
};

