[PR #3217] [CLOSED] Move from unique_together to constraints #12525

Closed
opened 2025-12-29 22:22:04 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/3217
Author: @hellerve
Created: 5/26/2019
Status: Closed

Base: developHead: fix-3146


📝 Commits (5)

  • ab0ea06 models: move from unique_together to constraints (fixes #3146)
  • 05db151 all: incorporate feedback regarding unique naming
  • 77dc701 all: rebase migrations on develop
  • 0b1ba51 models: change unique constraint names
  • cd68025 constraints: use new naming scheme

📊 Changes

10 files changed (+565 additions, -51 deletions)

View changed files

netbox/circuits/migrations/0016_modernize_unique_constraints.py (+29 -0)
📝 netbox/circuits/models.py (+12 -2)
netbox/dcim/migrations/0074_modernize_unique_constraints.py (+217 -0)
📝 netbox/dcim/models.py (+155 -37)
netbox/extras/migrations/0024_modernize_unique_constraints.py (+45 -0)
📝 netbox/extras/models.py (+25 -5)
netbox/ipam/migrations/0028_modernize_unique_constraints.py (+37 -0)
📝 netbox/ipam/models.py (+18 -6)
netbox/secrets/migrations/0007_modernize_unique_constraints.py (+21 -0)
📝 netbox/secrets/models.py (+6 -1)

📄 Description

Fixes: #3146

This PR moves from unique_together to constraints, as proposed in #3146.

As I see it, here are two open questions:

  • Is the naming of the constraints important? They need to be globally unique, and are thus pretty verbose right now; we could also add a helper to autogenerate those, but maybe that’s also not really ideal. Any input would be appreciated.
  • It creates a lot of migrations. Because they were created in bulk, they all have autogenerated names. I usually opt for descriptive names, and would thus be willing to name them if that turns out to be a problem!

Cheers


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/3217 **Author:** [@hellerve](https://github.com/hellerve) **Created:** 5/26/2019 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `fix-3146` --- ### 📝 Commits (5) - [`ab0ea06`](https://github.com/netbox-community/netbox/commit/ab0ea060183c4b3df4788eac21e6148a2fb3e97b) models: move from unique_together to constraints (fixes #3146) - [`05db151`](https://github.com/netbox-community/netbox/commit/05db151432b9a875edd3239722512fba033b76ea) all: incorporate feedback regarding unique naming - [`77dc701`](https://github.com/netbox-community/netbox/commit/77dc70141ecc88a80603ea499d2735a887945761) all: rebase migrations on develop - [`0b1ba51`](https://github.com/netbox-community/netbox/commit/0b1ba51ae2acc751343962fe474e940fdba33d84) models: change unique constraint names - [`cd68025`](https://github.com/netbox-community/netbox/commit/cd68025c26b1f7a78a744cf199302ad9be93c6ce) constraints: use new naming scheme ### 📊 Changes **10 files changed** (+565 additions, -51 deletions) <details> <summary>View changed files</summary> ➕ `netbox/circuits/migrations/0016_modernize_unique_constraints.py` (+29 -0) 📝 `netbox/circuits/models.py` (+12 -2) ➕ `netbox/dcim/migrations/0074_modernize_unique_constraints.py` (+217 -0) 📝 `netbox/dcim/models.py` (+155 -37) ➕ `netbox/extras/migrations/0024_modernize_unique_constraints.py` (+45 -0) 📝 `netbox/extras/models.py` (+25 -5) ➕ `netbox/ipam/migrations/0028_modernize_unique_constraints.py` (+37 -0) 📝 `netbox/ipam/models.py` (+18 -6) ➕ `netbox/secrets/migrations/0007_modernize_unique_constraints.py` (+21 -0) 📝 `netbox/secrets/models.py` (+6 -1) </details> ### 📄 Description ### Fixes: #3146 This PR moves from `unique_together` to `constraints`, as proposed in #3146. As I see it, here are two open questions: - [x] Is the naming of the constraints important? They need to be globally unique, and are thus pretty verbose right now; we could also add a helper to autogenerate those, but maybe that’s also not really ideal. Any input would be appreciated. - [x] It creates a _lot_ of migrations. Because they were created in bulk, they all have autogenerated names. I usually opt for descriptive names, and would thus be willing to name them if that turns out to be a problem! Cheers --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:22:04 +01:00
adam closed this issue 2025-12-29 22:22:04 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12525