|
|
|
@ -1,11 +1,11 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# Generated by Django 1.11 on 2018-06-12 11:24 |
|
|
|
# Generated by Django 1.11 on 2018-08-08 17:31 |
|
|
|
from __future__ import unicode_literals |
|
|
|
import os |
|
|
|
from json import load |
|
|
|
import os |
|
|
|
from django.core import serializers |
|
|
|
|
|
|
|
from django.db import migrations, models |
|
|
|
from django.core import serializers |
|
|
|
|
|
|
|
|
|
|
|
TMP_FILE = '/tmp/djing_ip_field_devapp_migrate.json' |
|
|
|
@ -13,9 +13,9 @@ TMP_FILE = '/tmp/djing_ip_field_devapp_migrate.json' |
|
|
|
|
|
|
|
def device_backup_info(apps, _): |
|
|
|
Device = apps.get_model('devapp', 'Device') |
|
|
|
obs = Device.objects.all() |
|
|
|
obs = Device.objects.exclude(ip_address=None).only('ip_address') |
|
|
|
with open(TMP_FILE, 'w') as f: |
|
|
|
serializers.serialize('json', obs, stream=f) |
|
|
|
serializers.serialize('json', obs, stream=f, fields=('ip_address',)) |
|
|
|
|
|
|
|
|
|
|
|
def device_restore_info_to_new_scheme(apps, _): |
|
|
|
@ -28,7 +28,6 @@ def device_restore_info_to_new_scheme(apps, _): |
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration): |
|
|
|
|
|
|
|
dependencies = [ |
|
|
|
('devapp', '0004_device_extra_data'), |
|
|
|
] |
|
|
|
@ -38,7 +37,7 @@ class Migration(migrations.Migration): |
|
|
|
migrations.AlterField( |
|
|
|
model_name='device', |
|
|
|
name='ip_address', |
|
|
|
field=models.GenericIPAddressField(blank=True, null=True, protocol='ipv4', verbose_name='Ip address'), |
|
|
|
field=models.GenericIPAddressField(blank=True, null=True, verbose_name='Ip address'), |
|
|
|
), |
|
|
|
migrations.RunPython(device_restore_info_to_new_scheme) |
|
|
|
] |