Skip to content

Commit 923c272

Browse files
committed
Fixes #4056: Repair schema migration for Rack.outer_unit (from #3569)
1 parent 03087e9 commit 923c272

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

docs/release-notes/version-2.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* [#4043](https://github.com/netbox-community/netbox/issues/4043) - Fix toggling of required fields in custom scripts
66
* [#4049](https://github.com/netbox-community/netbox/issues/4049) - Restore missing `tags` field in IPAM service serializer
7+
* [#4056](https://github.com/netbox-community/netbox/issues/4056) - Repair schema migration for Rack.outer_unit (from #3569)
78

89
---
910

netbox/dcim/migrations/0079_3569_rack_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def rack_status_to_slug(apps, schema_editor):
3737
def rack_outer_unit_to_slug(apps, schema_editor):
3838
Rack = apps.get_model('dcim', 'Rack')
3939
for id, slug in RACK_DIMENSION_CHOICES:
40-
Rack.objects.filter(status=str(id)).update(status=slug)
40+
Rack.objects.filter(outer_unit=str(id)).update(outer_unit=slug)
4141

4242

4343
class Migration(migrations.Migration):
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.db import migrations
2+
3+
RACK_DIMENSION_CHOICES = (
4+
(1000, 'mm'),
5+
(2000, 'in'),
6+
)
7+
8+
9+
def rack_outer_unit_to_slug(apps, schema_editor):
10+
Rack = apps.get_model('dcim', 'Rack')
11+
for id, slug in RACK_DIMENSION_CHOICES:
12+
Rack.objects.filter(outer_unit=str(id)).update(outer_unit=slug)
13+
14+
15+
class Migration(migrations.Migration):
16+
17+
dependencies = [
18+
('dcim', '0091_interface_type_other'),
19+
]
20+
21+
operations = [
22+
# Fixes a missed field migration from #3569; see bug #4056. The original migration has also been fixed,
23+
# so this can be omitted when squashing in the future.
24+
migrations.RunPython(
25+
code=rack_outer_unit_to_slug
26+
),
27+
]

0 commit comments

Comments
 (0)