Browse Source

Migrace | reorganizace migraci

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.
middleware_test
parent
commit
b4e0bf7348
  1. 0
      seminar/migrations/0001_squashed_0067_auto_20190814_0805.py.bak
  2. 41
      seminar/migrations/0058_problem_to_uloha_tema_clanek.py
  3. 2
      seminar/migrations/0065_treenode_polymorphic_ctype.py
  4. 31
      seminar/migrations/0066b_orgtextnode.py
  5. 29
      seminar/migrations/0066c_reseninode.py
  6. 2
      seminar/migrations/0067_auto_20190814_0805.py
  7. 2
      seminar/migrations/0077_auto_20200318_2146.py
  8. 27
      seminar/migrations/0078_otistenereseninode.py
  9. 2
      seminar/migrations/0079_clanek_resitelsky.py
  10. 18
      seminar/migrations/0080_zruseni_claneknode_a_konferanode.py
  11. 2
      seminar/migrations/0087_fix_polymorphism.py
  12. 2
      seminar/migrations/0088_perm_org_a_ucastnik.py
  13. 28
      seminar/migrations/0093_auto_20210330_2105.py

0
seminar/migrations/0001_squashed_0067_auto_20190814_0805.py → seminar/migrations/0001_squashed_0067_auto_20190814_0805.py.bak

41
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),
]

2
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 = [

31
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',),
),
]

29
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',),
),
]

2
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 = [

2
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 = [

27
seminar/migrations/0078_otistenereseninode.py

@ -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',),
),
]

2
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 = [

18
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',

2
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),

2
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 = [

28
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',
),
]
Loading…
Cancel
Save