|
|
|
# Generated by Django 2.2.4 on 2019-08-13 19:45
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
import django.db.models.deletion
|
|
|
|
|
|
|
|
def vyrob_problemum_ctypes(apps, schema_editor):
|
|
|
|
# Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html
|
|
|
|
# NOTE: Tahle migrace je špatně, 0087 ji opravuje. Možno squashnout pryč.
|
|
|
|
Problem = apps.get_model('seminar', 'Problem')
|
|
|
|
ContentType = apps.get_model('contenttypes', 'ContentType')
|
|
|
|
|
|
|
|
new_ct = ContentType.objects.get_for_model(Problem)
|
|
|
|
Problem.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct)
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
('contenttypes', '0002_remove_content_type_name'),
|
|
|
|
('seminar', '0065_treenode_polymorphic_ctype'),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='problem',
|
|
|
|
name='polymorphic_ctype',
|
|
|
|
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.problem_set+', to='contenttypes.ContentType'),
|
|
|
|
),
|
|
|
|
migrations.RunPython(vyrob_problemum_ctypes, migrations.RunPython.noop, elidable=True),
|
|
|
|
]
|