2018-03-26 03:12:01 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Generated by Django 1.10.7 on 2017-12-31 19:53
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2018-03-26 15:38:39 +00:00
|
|
|
('topologie', '0051_switchs_machine'),
|
2018-03-26 03:12:01 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def transfer_port(apps, schema_editor):
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
port = apps.get_model("topologie", "Port")
|
|
|
|
switch = apps.get_model("topologie", "NewSw")
|
|
|
|
port_list = port.objects.using(db_alias).all()
|
|
|
|
for p in port_list:
|
|
|
|
p.new_sw = switch.objects.filter(machine_ptr=p.switch.machine).first()
|
|
|
|
p.save()
|
|
|
|
|
|
|
|
def untransfer_port(apps, schema_editor):
|
|
|
|
return
|
|
|
|
|
|
|
|
operations = [
|
2018-03-26 15:38:39 +00:00
|
|
|
migrations.AlterUniqueTogether(
|
|
|
|
name='port',
|
|
|
|
unique_together=set([]),
|
|
|
|
),
|
2018-03-26 03:12:01 +00:00
|
|
|
migrations.RunPython(transfer_port, untransfer_port),
|
|
|
|
migrations.RemoveField(
|
|
|
|
model_name='port',
|
|
|
|
name='switch',
|
|
|
|
),
|
|
|
|
migrations.RenameField('Port', 'new_sw', 'switch')
|
|
|
|
]
|