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

method: {
        type: DataTypes.ENUM,

        values: [

"GET",

"POST",

"PATCH",

"DELETE"

        ],

      },

uri: {
        type: DataTypes.TEXT,

      },

route_name: {
        type: DataTypes.TEXT,

      },

acitve: {
        type: DataTypes.BOOLEAN,

        allowNull: false,
        defaultValue: false,

      },

is_menu: {
        type: DataTypes.BOOLEAN,

        allowNull: false,
        defaultValue: false,

      },

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

  urls.associate = (db) => {

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

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

  return urls;
};

