1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
netbox-community-netbox/netbox/ipam/migrations/0029_3569_ipaddress_fields.py

38 lines
824 B
Python
Raw Normal View History

2019-11-27 21:54:01 -05:00
from django.db import migrations, models
IPADDRESS_STATUS_CHOICES = (
(0, 'container'),
(1, 'active'),
(2, 'reserved'),
(3, 'deprecated'),
)
def ipaddress_status_to_slug(apps, schema_editor):
IPAddress = apps.get_model('ipam', 'IPAddress')
for id, slug in IPADDRESS_STATUS_CHOICES:
IPAddress.objects.filter(status=str(id)).update(status=slug)
class Migration(migrations.Migration):
atomic = False
dependencies = [
('ipam', '0028_3569_prefix_fields'),
]
operations = [
# IPAddress.status
migrations.AlterField(
model_name='ipaddress',
name='status',
field=models.CharField(default='active', max_length=50),
),
migrations.RunPython(
code=ipaddress_status_to_slug
),
]