Use UUID as primary key for JobResult model #3969

Closed
opened 2025-12-29 18:32:22 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Aug 11, 2020).

Proposed Changes

#2006 introduced a new JobResult model to enable background processing of reports and custom scripts. Like every other model in NetBox, JobResult includes an auto-incrementing integer field (id) which it uses as its primary key in the database. It also includes a randomly-generated UUID field, named job_id. I opened this issue to propose using job_id as the primary key for the model, and removing the built-in id field.

Justification

  • Eliminates a redundant unique field
  • JobResult instances are ephemeral in nature, so there's no need for a permanently sequential ID
  • The model already has created and completed timestamp fields to allow chronological ordering in either respect

I'm not 100% sold on the proposal myself, but wanted to open it up for discussion.

Originally created by @jeremystretch on GitHub (Aug 11, 2020). ### Proposed Changes #2006 introduced a new JobResult model to enable background processing of reports and custom scripts. Like every other model in NetBox, JobResult includes an auto-incrementing integer field (`id`) which it uses as its primary key in the database. It also includes a randomly-generated UUID field, named `job_id`. I opened this issue to propose using `job_id` as the primary key for the model, and removing the built-in `id` field. ### Justification - Eliminates a redundant unique field - JobResult instances are ephemeral in nature, so there's no need for a permanently sequential ID - The model already has `created` and `completed` timestamp fields to allow chronological ordering in either respect I'm not 100% sold on the proposal myself, but wanted to open it up for discussion.
adam added the type: housekeepingbeta labels 2025-12-29 18:32:22 +01:00
adam closed this issue 2025-12-29 18:32:22 +01:00
Author
Owner

@minitriga commented on GitHub (Aug 12, 2020):

I have a plugin that currently utilises the JobResults table and API endpoints. I don't think I have anything that would cause me not to support this change at the moment.

@minitriga commented on GitHub (Aug 12, 2020): I have a plugin that currently utilises the JobResults table and API endpoints. I don't think I have anything that would cause me not to support this change at the moment.
Author
Owner

@jeremystretch commented on GitHub (Aug 18, 2020):

In the interest of ensuring consistency across all REST API endpoints, I'm going to leave this as-is. JobResults can still be referenced by UUID, but the integer primary key attribute (id) will be used as the primary ID for the model.

@jeremystretch commented on GitHub (Aug 18, 2020): In the interest of ensuring consistency across all REST API endpoints, I'm going to leave this as-is. JobResults can still be referenced by UUID, but the integer primary key attribute (`id`) will be used as the primary ID for the model.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3969