[PR #10368] [MERGED] Closes #10361: Migrate from unique_together to UniqueConstraints #13616

Closed
opened 2025-12-29 23:19:53 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10368
Author: @jeremystretch
Created: 9/14/2022
Status: Merged
Merged: 9/27/2022
Merged by: @jeremystretch

Base: featureHead: 10361-unique-constraints


📝 Commits (3)

  • ec6457b Remove custom validate_unique() methods
  • f51415c Replace unique_together with UniqueConstraints
  • 7ff2cb7 Use templated app & model names for all unique constraints

📊 Changes

23 files changed (+800 additions, -240 deletions)

View changed files

netbox/circuits/migrations/0039_unique_constraints.py (+39 -0)
📝 netbox/circuits/models/circuits.py (+12 -2)
📝 netbox/circuits/models/providers.py (+1 -2)
netbox/dcim/migrations/0162_unique_constraints.py (+331 -0)
📝 netbox/dcim/models/cables.py (+1 -1)
📝 netbox/dcim/models/device_component_templates.py (+38 -57)
📝 netbox/dcim/models/device_components.py (+25 -37)
📝 netbox/dcim/models/devices.py (+34 -27)
📝 netbox/dcim/models/power.py (+12 -2)
📝 netbox/dcim/models/racks.py (+11 -6)
📝 netbox/dcim/models/sites.py (+24 -60)
📝 netbox/dcim/tests/test_models.py (+3 -3)
netbox/extras/migrations/0078_unique_constraints.py (+27 -0)
📝 netbox/extras/models/models.py (+12 -4)
netbox/ipam/migrations/0062_unique_constraints.py (+43 -0)
📝 netbox/ipam/models/fhrp.py (+6 -1)
📝 netbox/ipam/models/vlans.py (+20 -8)
netbox/tenancy/migrations/0008_unique_constraints.py (+35 -0)
📝 netbox/tenancy/models/contacts.py (+16 -5)
netbox/virtualization/migrations/0033_unique_constraints.py (+43 -0)

...and 3 more files

📄 Description

Closes: #10361

  • Replace all definitions of unique_together in model Meta classes with a constraints list
  • Remove all custom validate_unique() methods, which are no longer needed as Django 4.1 introduces native constraint validation

🔄 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/10368 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 9/14/2022 **Status:** ✅ Merged **Merged:** 9/27/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `10361-unique-constraints` --- ### 📝 Commits (3) - [`ec6457b`](https://github.com/netbox-community/netbox/commit/ec6457bcd386dd08061203959fe0c27d79bb9ca7) Remove custom validate_unique() methods - [`f51415c`](https://github.com/netbox-community/netbox/commit/f51415cf2c581b63bad0807b5d32f4d5c0231af9) Replace unique_together with UniqueConstraints - [`7ff2cb7`](https://github.com/netbox-community/netbox/commit/7ff2cb75a8fe40a464c180547a495c887a3fdab1) Use templated app & model names for all unique constraints ### 📊 Changes **23 files changed** (+800 additions, -240 deletions) <details> <summary>View changed files</summary> ➕ `netbox/circuits/migrations/0039_unique_constraints.py` (+39 -0) 📝 `netbox/circuits/models/circuits.py` (+12 -2) 📝 `netbox/circuits/models/providers.py` (+1 -2) ➕ `netbox/dcim/migrations/0162_unique_constraints.py` (+331 -0) 📝 `netbox/dcim/models/cables.py` (+1 -1) 📝 `netbox/dcim/models/device_component_templates.py` (+38 -57) 📝 `netbox/dcim/models/device_components.py` (+25 -37) 📝 `netbox/dcim/models/devices.py` (+34 -27) 📝 `netbox/dcim/models/power.py` (+12 -2) 📝 `netbox/dcim/models/racks.py` (+11 -6) 📝 `netbox/dcim/models/sites.py` (+24 -60) 📝 `netbox/dcim/tests/test_models.py` (+3 -3) ➕ `netbox/extras/migrations/0078_unique_constraints.py` (+27 -0) 📝 `netbox/extras/models/models.py` (+12 -4) ➕ `netbox/ipam/migrations/0062_unique_constraints.py` (+43 -0) 📝 `netbox/ipam/models/fhrp.py` (+6 -1) 📝 `netbox/ipam/models/vlans.py` (+20 -8) ➕ `netbox/tenancy/migrations/0008_unique_constraints.py` (+35 -0) 📝 `netbox/tenancy/models/contacts.py` (+16 -5) ➕ `netbox/virtualization/migrations/0033_unique_constraints.py` (+43 -0) _...and 3 more files_ </details> ### 📄 Description ### Closes: #10361 - Replace all definitions of `unique_together` in model `Meta` classes with a `constraints` list - Remove all custom `validate_unique()` methods, which are no longer needed as Django 4.1 introduces native constraint validation --- <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 23:19:53 +01:00
adam closed this issue 2025-12-29 23:19:53 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13616