mirror of https://gitlab.federez.net/re2o/re2o
committed by
chirac
7 changed files with 112 additions and 43 deletions
@ -0,0 +1,26 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0046_auto_20180326_0129'), |
||||
|
] |
||||
|
|
||||
|
|
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='NewAccessPoint', |
||||
|
fields=[ |
||||
|
('machine_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='machines.Machine')), |
||||
|
('location', models.CharField(help_text="Détails sur la localisation de l'AP", max_length=255, null=True, blank=True)), |
||||
|
], |
||||
|
bases=('machines.machine',), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,39 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0047_ap_machine'), |
||||
|
] |
||||
|
|
||||
|
def transfer_ap(apps, schema_editor): |
||||
|
db_alias = schema_editor.connection.alias |
||||
|
ap = apps.get_model("topologie", "AccessPoint") |
||||
|
new_ap = apps.get_model("topologie", "NewAccessPoint") |
||||
|
ap_list = ap.objects.using(db_alias).all() |
||||
|
for borne in ap_list: |
||||
|
new_borne = new_ap() |
||||
|
new_borne.machine_ptr_id = borne.machine.pk |
||||
|
new_borne.__dict__.update(borne.machine.__dict__) |
||||
|
new_borne.location = borne.location |
||||
|
new_borne.save() |
||||
|
|
||||
|
def untransfer_ap(apps, schema_editor): |
||||
|
return |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(transfer_ap, untransfer_ap), |
||||
|
migrations.DeleteModel( |
||||
|
name='AccessPoint', |
||||
|
), |
||||
|
migrations.RenameModel( |
||||
|
old_name='NewAccessPoint', |
||||
|
new_name='AccessPoint', |
||||
|
), |
||||
|
] |
||||
Loading…
Reference in new issue