# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-15 18:56
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations
import stats.models


def json_to_jsonb(apps, schema_editor):

    Mission = apps.get_model('stats', 'Mission')
    Player = apps.get_model('stats', 'Player')
    PlayerMission = apps.get_model('stats', 'PlayerMission')
    PlayerAircraft = apps.get_model('stats', 'PlayerAircraft')
    Sortie = apps.get_model('stats', 'Sortie')
    LogEntry = apps.get_model('stats', 'LogEntry')

    for m in Mission.objects.all():
        m.score_dict_new = m.score_dict
        m.save()

    for m in Player.objects.all():
        m.sorties_cls_new = m.sorties_cls
        m.ammo_new = m.ammo
        m.killboard_pvp_new = m.killboard_pvp
        m.killboard_pve_new = m.killboard_pve
        m.save()

    for m in PlayerMission.objects.all():
        m.ammo_new = m.ammo
        m.killboard_pvp_new = m.killboard_pvp
        m.killboard_pve_new = m.killboard_pve
        m.save()

    for m in PlayerAircraft.objects.all():
        m.ammo_new = m.ammo
        m.killboard_pvp_new = m.killboard_pvp
        m.killboard_pve_new = m.killboard_pve
        m.save()

    for m in Sortie.objects.all():
        m.ammo_new = m.ammo
        m.killboard_pvp_new = m.killboard_pvp
        m.killboard_pve_new = m.killboard_pve

        m.score_dict_new = m.score_dict
        m.bonus_new = m.bonus
        m.debug_new = m.debug
        m.save()

    for m in LogEntry.objects.all():
        m.extra_data_new = m.extra_data
        m.save()


class Migration(migrations.Migration):

    dependencies = [
        ('stats', '0009_french'),
    ]

    operations = [
        migrations.AddField(
            model_name='logentry',
            name='extra_data_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='mission',
            name='score_dict_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='player',
            name='ammo_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=stats.models.default_ammo),
        ),
        migrations.AddField(
            model_name='player',
            name='killboard_pve_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='player',
            name='killboard_pvp_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='player',
            name='sorties_cls_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=stats.models.default_sorties_cls),
        ),
        migrations.AddField(
            model_name='playeraircraft',
            name='ammo_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=stats.models.default_ammo),
        ),
        migrations.AddField(
            model_name='playeraircraft',
            name='killboard_pve_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='playeraircraft',
            name='killboard_pvp_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='playermission',
            name='ammo_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=stats.models.default_ammo),
        ),
        migrations.AddField(
            model_name='playermission',
            name='killboard_pve_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='playermission',
            name='killboard_pvp_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='sortie',
            name='ammo_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=stats.models.default_ammo),
        ),
        migrations.AddField(
            model_name='sortie',
            name='bonus_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='sortie',
            name='debug_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='sortie',
            name='killboard_pve_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='sortie',
            name='killboard_pvp_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name='sortie',
            name='score_dict_new',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
        ),
        migrations.RunPython(json_to_jsonb),
    ]
