Pavel "LEdoian" Turinsky
5 years ago
4 changed files with 60 additions and 40 deletions
@ -1,20 +0,0 @@ |
|||
# Generated by Django 2.2.4 on 2019-08-13 19:36 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('contenttypes', '0002_remove_content_type_name'), |
|||
('seminar', '0001_initial'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='treenode', |
|||
name='polymorphic_ctype', |
|||
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.treenode_set+', to='contenttypes.ContentType'), |
|||
), |
|||
] |
@ -1,20 +0,0 @@ |
|||
# Generated by Django 2.2.4 on 2019-08-13 19:45 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('contenttypes', '0002_remove_content_type_name'), |
|||
('seminar', '0002_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'), |
|||
), |
|||
] |
@ -0,0 +1,31 @@ |
|||
# Generated by Django 2.2.4 on 2019-08-13 19:36 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
def vyrob_treenodum_ctypes(apps, schema_editor): |
|||
# Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html |
|||
# XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i) |
|||
TreeNode = apps.get_model('seminar', 'TreeNode') |
|||
ContentType = apps.get_model('contenttypes', 'ContentType') |
|||
|
|||
new_ct = ContentType.objects.get_for_model(TreeNode) |
|||
TreeNode.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct) |
|||
|
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('contenttypes', '0002_remove_content_type_name'), |
|||
('seminar', '0064_auto_20190610_2358'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='treenode', |
|||
name='polymorphic_ctype', |
|||
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.treenode_set+', to='contenttypes.ContentType'), |
|||
), |
|||
migrations.RunPython(vyrob_treenodum_ctypes, migrations.RunPython.noop), |
|||
] |
@ -0,0 +1,29 @@ |
|||
# 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 |
|||
# XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i) |
|||
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), |
|||
] |
Loading…
Reference in new issue