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

status: {
        type: DataTypes.TEXT,

      },

asset_id: {
        type: DataTypes.TEXT,

      },

description: {
        type: DataTypes.TEXT,

      },

date_uploaded: {
        type: DataTypes.DATE,

      },

year: {
        type: DataTypes.TEXT,

      },

category: {
        type: DataTypes.TEXT,

      },

brand: {
        type: DataTypes.TEXT,

      },

product: {
        type: DataTypes.TEXT,

      },

asset_type: {
        type: DataTypes.TEXT,

      },

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

  adbuilder_assets.associate = (db) => {

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

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

  return adbuilder_assets;
};

