Create parallel Player/Account fields and copy all

This commit is contained in:
Griatch 2017-07-06 22:29:52 +02:00
parent ee0e9cc053
commit 63c96de443
10 changed files with 226 additions and 2 deletions

View file

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-05 17:27
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('accounts', '0002_copy_player_to_account'),
('scripts', '0008_auto_20170606_1731'),
]
operations = [
migrations.AddField(
model_name='scriptdb',
name='db_account',
field=models.ForeignKey(blank=True, help_text=b'the account to store this script on (should not be set if db_obj is set)', null=True, on_delete=django.db.models.deletion.CASCADE, to='accounts.AccountDB', verbose_name=b'scripted account'),
),
]

View file

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-05 17:36
from __future__ import unicode_literals
from django.db import migrations
def forwards(apps, schema_editor):
try:
apps.get_model('players', 'PlayerDB')
except LookupError:
return
AccountDB = apps.get_model('accounts', 'AccountDB')
ScriptDB = apps.get_model('scripts', 'ScriptDB')
for script in ScriptDB.objects.all():
player = script.db_player
if player:
account = AccountDB.objects.get(id=player.id)
script.db_account = account
script.save(update_fields=['db_account'])
class Migration(migrations.Migration):
dependencies = [
('scripts', '0009_scriptdb_db_account'),
]
operations = [
migrations.RunPython(forwards)
]