Fixes #4027: Repair schema migration for #3569 to convert IP addresses with DHCP status

This commit is contained in:
Jeremy Stretch
2020-01-28 12:49:00 -05:00
parent ac3cac1b1c
commit 0f8534e65e
3 changed files with 23 additions and 1 deletions

View File

@@ -2,10 +2,10 @@ from django.db import migrations, models
IPADDRESS_STATUS_CHOICES = (
(0, 'container'),
(1, 'active'),
(2, 'reserved'),
(3, 'deprecated'),
(5, 'dhcp'),
)
IPADDRESS_ROLE_CHOICES = (

View File

@@ -0,0 +1,21 @@
from django.db import migrations
def ipaddress_status_dhcp_to_slug(apps, schema_editor):
IPAddress = apps.get_model('ipam', 'IPAddress')
IPAddress.objects.filter(status='5').update(status='dhcp')
class Migration(migrations.Migration):
dependencies = [
('ipam', '0033_deterministic_ordering'),
]
operations = [
# Fixes a missed integer substitution from #3569; see bug #4027. The original migration has also been fixed,
# so this can be omitted when squashing in the future.
migrations.RunPython(
code=ipaddress_status_dhcp_to_slug
),
]