mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Ditched VMInterface in favor of reusing dcim.Interface
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.4 on 2017-08-18 19:31
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def set_interface_type(apps, schema_editor):
|
||||
"""
|
||||
Set the interface_type field to 'Interface' for all IP addresses assigned to an Interface.
|
||||
"""
|
||||
Interface = apps.get_model('dcim', 'Interface')
|
||||
interface_type = ContentType.objects.get_for_model(Interface)
|
||||
IPAddress = apps.get_model('ipam', 'IPAddress')
|
||||
IPAddress.objects.filter(interface__isnull=False).update(interface_type=interface_type)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('ipam', '0018_remove_service_uniqueness_constraint'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='ipaddress',
|
||||
name='interface_type',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='contenttypes.ContentType'),
|
||||
),
|
||||
migrations.RunPython(set_interface_type),
|
||||
migrations.AlterField(
|
||||
model_name='IPAddress',
|
||||
name='interface',
|
||||
field=models.PositiveIntegerField(blank=True, null=True),
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='IPAddress',
|
||||
old_name='interface',
|
||||
new_name='interface_id',
|
||||
)
|
||||
]
|
Reference in New Issue
Block a user