module.exports = function (sequelize, DataTypes) {
  const Rol = sequelize.define(
    "Rol",
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },
      name: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
      },
    },
    {
      tableName: "roles",
      freezeTableName: true,
      timestamps: true,
    }
  );
  Rol.associate = function (models) {
    Rol.Users = Rol.belongsToMany(models.User, {
      through: models.UserRoles,
      foreignKey: "rolId",
    });
  };
  return Rol;
};
