mirror of https://gitlab.federez.net/re2o/re2o
committed by
root
8 changed files with 174 additions and 87 deletions
@ -0,0 +1,61 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-10-24 23:54 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
def create_move_room(apps, schema_editor): |
|||
User = apps.get_model('users', 'User') |
|||
Adherent = apps.get_model('users', 'Adherent') |
|||
Club = apps.get_model('users', 'Club') |
|||
db_alias = schema_editor.connection.alias |
|||
users = Adherent.objects.using(db_alias).all() |
|||
clubs = Club.objects.using(db_alias).all() |
|||
for user in users: |
|||
user.room_adherent_id = user.room_id |
|||
user.save(using=db_alias) |
|||
for user in clubs: |
|||
user.room_club_id = user.room_id |
|||
user.save(using=db_alias) |
|||
|
|||
|
|||
def delete_move_room(apps, schema_editor): |
|||
User = apps.get_model('users', 'User') |
|||
Adherent = apps.get_model('users', 'Adherent') |
|||
Club = apps.get_model('users', 'Club') |
|||
db_alias = schema_editor.connection.alias |
|||
users = Adherent.objects.using(db_alias).all() |
|||
clubs = Club.objects.using(db_alias).all() |
|||
for user in users: |
|||
user.room_id = user.room_adherent_id |
|||
user.save(using=db_alias) |
|||
for user in clubs: |
|||
user.room_id = user.room_club_id |
|||
user.save(using=db_alias) |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0031_auto_20171015_2033'), |
|||
('users', '0057_auto_20171023_0301'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='adherent', |
|||
name='room_adherent', |
|||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='topologie.Room'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='club', |
|||
name='room_club', |
|||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='topologie.Room'), |
|||
), |
|||
migrations.RunPython(create_move_room, delete_move_room), |
|||
migrations.RemoveField( |
|||
model_name='user', |
|||
name='room', |
|||
), |
|||
] |
|||
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-10-25 16:54 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('users', '0058_auto_20171025_0154'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RenameField( |
|||
model_name='adherent', |
|||
old_name='room_adherent', |
|||
new_name='room', |
|||
), |
|||
migrations.RenameField( |
|||
model_name='club', |
|||
old_name='room_club', |
|||
new_name='room', |
|||
), |
|||
] |
|||
Loading…
Reference in new issue