From b4e0bf734830059960038187698e7f08bc291cc1 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Tue, 30 Mar 2021 21:10:20 +0200 Subject: [PATCH] Migrace | reorganizace migraci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zatím neověřeně funkční reorganizace migrací, která odstraňuje situaci, kdy existovaly Node, ale neexistovalo django-polymorphic. Opravuje problém, kdy zmigrované problémy nemají jména (a asi i nic dalšího), možná přináší jiné problémy, nutné ověřit. --- ...1_squashed_0067_auto_20190814_0805.py.bak} | 0 .../0058_problem_to_uloha_tema_clanek.py | 41 +++++++++++-------- .../0065_treenode_polymorphic_ctype.py | 2 +- seminar/migrations/0066b_orgtextnode.py | 31 ++++++++++++++ seminar/migrations/0066c_reseninode.py | 29 +++++++++++++ seminar/migrations/0067_auto_20190814_0805.py | 2 +- seminar/migrations/0077_auto_20200318_2146.py | 2 +- seminar/migrations/0078_otistenereseninode.py | 27 ------------ seminar/migrations/0079_clanek_resitelsky.py | 2 +- .../0080_zruseni_claneknode_a_konferanode.py | 18 -------- seminar/migrations/0087_fix_polymorphism.py | 2 +- .../migrations/0088_perm_org_a_ucastnik.py | 2 +- seminar/migrations/0093_auto_20210330_2105.py | 28 +++++++++++++ 13 files changed, 119 insertions(+), 67 deletions(-) rename seminar/migrations/{0001_squashed_0067_auto_20190814_0805.py => 0001_squashed_0067_auto_20190814_0805.py.bak} (100%) create mode 100644 seminar/migrations/0066b_orgtextnode.py create mode 100644 seminar/migrations/0066c_reseninode.py delete mode 100644 seminar/migrations/0078_otistenereseninode.py create mode 100644 seminar/migrations/0093_auto_20210330_2105.py diff --git a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py.bak similarity index 100% rename from seminar/migrations/0001_squashed_0067_auto_20190814_0805.py rename to seminar/migrations/0001_squashed_0067_auto_20190814_0805.py.bak diff --git a/seminar/migrations/0058_problem_to_uloha_tema_clanek.py b/seminar/migrations/0058_problem_to_uloha_tema_clanek.py index 7d651edb..ebd2d6fb 100644 --- a/seminar/migrations/0058_problem_to_uloha_tema_clanek.py +++ b/seminar/migrations/0058_problem_to_uloha_tema_clanek.py @@ -2,9 +2,10 @@ # Generated by Django 1.11.20 on 2019-05-17 17:44 from __future__ import unicode_literals -from django.db import migrations +from django.db import migrations, models from django.db.models import Q +import django.db.models.deletion def poskladej_strom(apps, rodic, *texty): Text = apps.get_model('seminar', 'Text') @@ -31,6 +32,13 @@ def poskladej_strom(apps, rodic, *texty): tn.succ = textnode tn.save() tn = tn.succ +def problem_to_polymorphic_Problem(apps,schema_editor): + 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) + def uloha_to_Uloha(apps,schema_editor): Problem = apps.get_model('seminar', 'Problem') @@ -41,23 +49,24 @@ def uloha_to_Uloha(apps,schema_editor): TextNode = apps.get_model('seminar', 'TextNode') ulohy = Problem.objects.filter(typ = 'uloha') - for uold in ulohy: + for uold in ulohy[1:]: unew = Uloha.objects.create( - problem_ptr = uold, # Zakomentované fieldy by se už měly nacházet v příslušném problému - #nazev = uold.nazev, - #stav = uold.stav, - #zamereni = uold.zamereni, - #poznamka = uold.poznamka, - #autor = uold.autor, - #kod = uold.kod, + nazev = uold.nazev, + stav = uold.stav, + zamereni = uold.zamereni, + poznamka = uold.poznamka, + autor = uold.autor, + kod = uold.kod, cislo_zadani = uold.cislo_zadani_old, cislo_reseni = uold.cislo_reseni_old, max_body = uold.body, - #vytvoreno = uold.vytvoreno, + vytvoreno = uold.vytvoreno, ) -# unew.opravovatele.add(*uold.opravovatele.all()) unew.save() + unew.opravovatele.add(*uold.opravovatele.all()) + + return # Nody: zadani_node = UlohaZadaniNode.objects.create(uloha = unew) @@ -94,7 +103,7 @@ def clanek_to_Clanek(apps,schema_editor): raise ValueError("Různá čísla zadání a řešení u článku! (Článek: {})".format(cl.nazev)) clnew = Clanek.objects.create( - problem_ptr = cl, + problem_ptr_id = cl.id, # Problém by nemělo být potřeba upravovat cislo = cislo, # Body ignorujeme, protože už jsou v hodnocení @@ -149,13 +158,13 @@ def tema_to_Tema(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('seminar', '0057_reseni_to_reseni_hodnoceni'), + ('seminar', '0087_fix_polymorphism'), ] operations = [ # ashes to Ashes, dust to Dust.... migrations.RunPython(uloha_to_Uloha, migrations.RunPython.noop), - migrations.RunPython(tema_to_Tema, migrations.RunPython.noop), - migrations.RunPython(clanek_to_Clanek, migrations.RunPython.noop), - migrations.RunPython(konfery_rucne, migrations.RunPython.noop), + # migrations.RunPython(tema_to_Tema, migrations.RunPython.noop), + # migrations.RunPython(clanek_to_Clanek, migrations.RunPython.noop), + # migrations.RunPython(konfery_rucne, migrations.RunPython.noop), ] diff --git a/seminar/migrations/0065_treenode_polymorphic_ctype.py b/seminar/migrations/0065_treenode_polymorphic_ctype.py index cb65d8f1..88917d77 100644 --- a/seminar/migrations/0065_treenode_polymorphic_ctype.py +++ b/seminar/migrations/0065_treenode_polymorphic_ctype.py @@ -18,7 +18,7 @@ class Migration(migrations.Migration): dependencies = [ ('contenttypes', '0002_remove_content_type_name'), - ('seminar', '0064_auto_20190610_2358'), + ('seminar', '0057_reseni_to_reseni_hodnoceni'), ] operations = [ diff --git a/seminar/migrations/0066b_orgtextnode.py b/seminar/migrations/0066b_orgtextnode.py new file mode 100644 index 00000000..ecf509bb --- /dev/null +++ b/seminar/migrations/0066b_orgtextnode.py @@ -0,0 +1,31 @@ + +# 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', '0066_problem_polymorphic_ctype'), + ] + + operations = [ + migrations.CreateModel( + name='OrgTextNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('org_verejny', models.BooleanField(default=True, help_text='Pokud ano, bude org pod článkem podepsaný', verbose_name='Org je veřejný?')), + ('organizator', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='seminar.Organizator', verbose_name='Organizátor')), + ], + options={ + 'verbose_name': 'Organizátorský článek (Node)', + 'verbose_name_plural': 'Organizátorské články (Node)', + 'db_table': 'seminar_nodes_orgtextnode', + }, + bases=('seminar.treenode',), + ), + + ] diff --git a/seminar/migrations/0066c_reseninode.py b/seminar/migrations/0066c_reseninode.py new file mode 100644 index 00000000..ae3e5a4e --- /dev/null +++ b/seminar/migrations/0066c_reseninode.py @@ -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 + + +class Migration(migrations.Migration): + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ('seminar', '0066b_orgtextnode'), + ] + + operations = [ + migrations.CreateModel( + name='ReseniNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('reseni', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Reseni', verbose_name='reseni')), + ], + options={ + 'verbose_name': 'Otištěné řešení (Node)', + 'verbose_name_plural': 'Otištěná řešení (Node)', + 'db_table': 'seminar_nodes_otistene_reseni', + }, + bases=('seminar.treenode',), + ), + + ] diff --git a/seminar/migrations/0067_auto_20190814_0805.py b/seminar/migrations/0067_auto_20190814_0805.py index 8a72a659..04d333a0 100644 --- a/seminar/migrations/0067_auto_20190814_0805.py +++ b/seminar/migrations/0067_auto_20190814_0805.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('seminar', '0066_problem_polymorphic_ctype'), + ('seminar', '0064_auto_20190610_2358'), ] operations = [ diff --git a/seminar/migrations/0077_auto_20200318_2146.py b/seminar/migrations/0077_auto_20200318_2146.py index 50053d9c..cc0e8c15 100644 --- a/seminar/migrations/0077_auto_20200318_2146.py +++ b/seminar/migrations/0077_auto_20200318_2146.py @@ -7,7 +7,7 @@ import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ - ('seminar', '0076_auto_20200228_2013'), + ('seminar', '0066c_reseninode'), ] operations = [ diff --git a/seminar/migrations/0078_otistenereseninode.py b/seminar/migrations/0078_otistenereseninode.py deleted file mode 100644 index 2f426a17..00000000 --- a/seminar/migrations/0078_otistenereseninode.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 2.2.9 on 2020-03-18 23:59 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('seminar', '0077_auto_20200318_2146'), - ] - - operations = [ - migrations.CreateModel( - name='OtisteneReseniNode', - fields=[ - ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), - ('reseni', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Reseni', verbose_name='reseni')), - ], - options={ - 'verbose_name': 'Otištěné řešení (Node)', - 'verbose_name_plural': 'Otištěná řešení (Node)', - 'db_table': 'seminar_nodes_otistene_reseni', - }, - bases=('seminar.treenode',), - ), - ] diff --git a/seminar/migrations/0079_clanek_resitelsky.py b/seminar/migrations/0079_clanek_resitelsky.py index f41cdc51..88ad06eb 100644 --- a/seminar/migrations/0079_clanek_resitelsky.py +++ b/seminar/migrations/0079_clanek_resitelsky.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('seminar', '0078_otistenereseninode'), + ('seminar', '0076_auto_20200228_2013'), ] operations = [ diff --git a/seminar/migrations/0080_zruseni_claneknode_a_konferanode.py b/seminar/migrations/0080_zruseni_claneknode_a_konferanode.py index 34c22249..ddf3cc8e 100644 --- a/seminar/migrations/0080_zruseni_claneknode_a_konferanode.py +++ b/seminar/migrations/0080_zruseni_claneknode_a_konferanode.py @@ -31,28 +31,10 @@ class Migration(migrations.Migration): model_name='konfera', name='ucastnici', ), - migrations.CreateModel( - name='OrgTextNode', - fields=[ - ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), - ('org_verejny', models.BooleanField(default=True, help_text='Pokud ano, bude org pod článkem podepsaný', verbose_name='Org je veřejný?')), - ('organizator', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='seminar.Organizator', verbose_name='Organizátor')), - ], - options={ - 'verbose_name': 'Organizátorský článek (Node)', - 'verbose_name_plural': 'Organizátorské články (Node)', - 'db_table': 'seminar_nodes_orgtextnode', - }, - bases=('seminar.treenode',), - ), migrations.RemoveField( model_name='konfera', name='id', ), - migrations.RenameModel( - old_name='OtisteneReseniNode', - new_name='ReseniNode', - ), migrations.RemoveField( model_name='clanek', name='cislo', diff --git a/seminar/migrations/0087_fix_polymorphism.py b/seminar/migrations/0087_fix_polymorphism.py index 40ce9adf..e7852c42 100644 --- a/seminar/migrations/0087_fix_polymorphism.py +++ b/seminar/migrations/0087_fix_polymorphism.py @@ -41,7 +41,7 @@ def fix_problem(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('seminar', '0086_auto_20200819_0959'), + ('seminar', '0077_auto_20200318_2146'), ] operations = [ migrations.RunPython(fix_treenode, migrations.RunPython.noop), diff --git a/seminar/migrations/0088_perm_org_a_ucastnik.py b/seminar/migrations/0088_perm_org_a_ucastnik.py index ca6190dd..febcf141 100644 --- a/seminar/migrations/0088_perm_org_a_ucastnik.py +++ b/seminar/migrations/0088_perm_org_a_ucastnik.py @@ -27,7 +27,7 @@ def add_perms(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('seminar', '0087_fix_polymorphism'), + ('seminar', '0086_auto_20200819_0959'), ] operations = [ diff --git a/seminar/migrations/0093_auto_20210330_2105.py b/seminar/migrations/0093_auto_20210330_2105.py new file mode 100644 index 00000000..06132eca --- /dev/null +++ b/seminar/migrations/0093_auto_20210330_2105.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.12 on 2021-03-30 19:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0092_auto_20210309_2049'), + ] + + operations = [ + migrations.DeleteModel( + name='VysledkyCelkemKCislu', + ), + migrations.DeleteModel( + name='VysledkyKCislu', + ), + migrations.DeleteModel( + name='VysledkyKCisluOdjakziva', + ), + migrations.DeleteModel( + name='VysledkyKCisluZaRocnik', + ), + migrations.DeleteModel( + name='VysledkyZaCislo', + ), + ]