mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
#4721: Tweak migrations to ensure Interface.device cannot be null
This commit is contained in:
parent
1f9cdc71d4
commit
6abb7e8f4d
@ -1,6 +1,5 @@
|
||||
# Generated by Django 3.0.6 on 2020-06-22 16:03
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -15,4 +14,11 @@ class Migration(migrations.Migration):
|
||||
model_name='interface',
|
||||
name='virtual_machine',
|
||||
),
|
||||
# device is now a required field
|
||||
migrations.AlterField(
|
||||
model_name='interface',
|
||||
name='device',
|
||||
field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, related_name='interfaces', to='dcim.Device'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
@ -51,8 +51,8 @@ def replicate_interfaces(apps, schema_editor):
|
||||
# Verify that all interfaces have been replicated
|
||||
assert replicated_count == original_interfaces.count(), "Replicated interfaces count does not match original count!"
|
||||
|
||||
# Delete original VM interfaces
|
||||
original_interfaces.delete()
|
||||
# Delete all interfaces not assigned to a Device
|
||||
Interface.objects.filter(device__isnull=True).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
Loading…
Reference in New Issue
Block a user