mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Consolidate #3569 field migrations by model
This commit is contained in:
12
netbox/dcim/migrations/0078_3569_site_fields.py
Normal file
12
netbox/dcim/migrations/0078_3569_site_fields.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0077_power_types'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
@ -8,6 +8,14 @@ RACK_TYPE_CHOICES = (
|
||||
(1100, 'wall-cabinet'),
|
||||
)
|
||||
|
||||
RACK_STATUS_CHOICES = (
|
||||
(0, 'reserved'),
|
||||
(1, 'available'),
|
||||
(2, 'planned'),
|
||||
(3, 'active'),
|
||||
(4, 'deprecated'),
|
||||
)
|
||||
|
||||
|
||||
def rack_type_to_slug(apps, schema_editor):
|
||||
Rack = apps.get_model('dcim', 'Rack')
|
||||
@ -15,14 +23,22 @@ def rack_type_to_slug(apps, schema_editor):
|
||||
Rack.objects.filter(type=str(id)).update(type=slug)
|
||||
|
||||
|
||||
def rack_status_to_slug(apps, schema_editor):
|
||||
Rack = apps.get_model('dcim', 'Rack')
|
||||
for id, slug in RACK_STATUS_CHOICES:
|
||||
Rack.objects.filter(status=str(id)).update(status=slug)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0077_power_types'),
|
||||
('dcim', '0078_3569_site_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
||||
# Rack.type
|
||||
migrations.AlterField(
|
||||
model_name='rack',
|
||||
name='type',
|
||||
@ -36,4 +52,14 @@ class Migration(migrations.Migration):
|
||||
name='type',
|
||||
field=models.CharField(blank=True, max_length=50),
|
||||
),
|
||||
|
||||
# Rack.status
|
||||
migrations.AlterField(
|
||||
model_name='rack',
|
||||
name='status',
|
||||
field=models.CharField(default='active', max_length=50),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=rack_status_to_slug
|
||||
),
|
||||
]
|
@ -1,34 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
RACK_STATUS_CHOICES = (
|
||||
(0, 'reserved'),
|
||||
(1, 'available'),
|
||||
(2, 'planned'),
|
||||
(3, 'active'),
|
||||
(4, 'deprecated'),
|
||||
)
|
||||
|
||||
|
||||
def rack_status_to_slug(apps, schema_editor):
|
||||
Rack = apps.get_model('dcim', 'Rack')
|
||||
for id, slug in RACK_STATUS_CHOICES:
|
||||
Rack.objects.filter(status=str(id)).update(status=slug)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0078_rack_type_to_slug'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='rack',
|
||||
name='status',
|
||||
field=models.CharField(default='active', max_length=50),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=rack_status_to_slug
|
||||
),
|
||||
]
|
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0080_device_face_to_slug'),
|
||||
('dcim', '0079_3569_rack_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0079_rack_status_to_slug'),
|
||||
('dcim', '0080_3569_devicetype_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
@ -91,7 +91,7 @@ class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0081_devicetype_subdevicerole_to_slug'),
|
||||
('dcim', '0081_3569_device_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
Reference in New Issue
Block a user