Write data migration for ohlhafv challenges

This commit is contained in:
Jan Tuomi
2018-01-28 23:38:31 +02:00
parent ce1f4eb7c9
commit 9eae16110c
3 changed files with 34 additions and 2 deletions
+1 -1
View File
@@ -15,4 +15,4 @@ class PresetRoleTranslationOptions(TranslationOptions):
class CustomRoleTranslationOptions(TranslationOptions):
""" Class for CustomROle translation options"""
fields = ()
fields = ()
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-01-28 21:31
from __future__ import unicode_literals
from django.db import migrations
def migrate_ohlhafv(apps, schema_editor):
NewOhlhafvChallenge = apps.get_model('ohlhafv', 'OhlhafvChallenge')
OldOhlhafvChallenge = apps.get_model('webapp', 'OhlhafvChallenge')
for challenge in OldOhlhafvChallenge.objects.all():
NewOhlhafvChallenge.objects.create(
id=challenge.id,
challenger=challenge.challenger,
victim=challenge.victim,
challenger_email=challenge.challenger_email,
victim_email=challenge.victim_email,
series=challenge.series,
message=challenge.message,
)
class Migration(migrations.Migration):
dependencies = [
('webapp', '0039_delete_kaehmy_models'),
('ohlhafv', '0001_initial'),
]
operations = [
migrations.RunPython(migrate_ohlhafv),
]
@@ -8,7 +8,7 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('webapp', '0039_delete_kaehmy_models'),
('webapp', '0040_migrate_ohlhafvchallenge'),
]
operations = [