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.
This commit is contained in:
parent
e5ab448700
commit
b4e0bf7348
13 changed files with 119 additions and 67 deletions
|
@ -2,9 +2,10 @@
|
||||||
# Generated by Django 1.11.20 on 2019-05-17 17:44
|
# Generated by Django 1.11.20 on 2019-05-17 17:44
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations, models
|
||||||
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
def poskladej_strom(apps, rodic, *texty):
|
def poskladej_strom(apps, rodic, *texty):
|
||||||
Text = apps.get_model('seminar', 'Text')
|
Text = apps.get_model('seminar', 'Text')
|
||||||
|
@ -31,6 +32,13 @@ def poskladej_strom(apps, rodic, *texty):
|
||||||
tn.succ = textnode
|
tn.succ = textnode
|
||||||
tn.save()
|
tn.save()
|
||||||
tn = tn.succ
|
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):
|
def uloha_to_Uloha(apps,schema_editor):
|
||||||
Problem = apps.get_model('seminar', 'Problem')
|
Problem = apps.get_model('seminar', 'Problem')
|
||||||
|
@ -41,23 +49,24 @@ def uloha_to_Uloha(apps,schema_editor):
|
||||||
TextNode = apps.get_model('seminar', 'TextNode')
|
TextNode = apps.get_model('seminar', 'TextNode')
|
||||||
|
|
||||||
ulohy = Problem.objects.filter(typ = 'uloha')
|
ulohy = Problem.objects.filter(typ = 'uloha')
|
||||||
for uold in ulohy:
|
for uold in ulohy[1:]:
|
||||||
unew = Uloha.objects.create(
|
unew = Uloha.objects.create(
|
||||||
problem_ptr = uold,
|
|
||||||
# Zakomentované fieldy by se už měly nacházet v příslušném problému
|
# Zakomentované fieldy by se už měly nacházet v příslušném problému
|
||||||
#nazev = uold.nazev,
|
nazev = uold.nazev,
|
||||||
#stav = uold.stav,
|
stav = uold.stav,
|
||||||
#zamereni = uold.zamereni,
|
zamereni = uold.zamereni,
|
||||||
#poznamka = uold.poznamka,
|
poznamka = uold.poznamka,
|
||||||
#autor = uold.autor,
|
autor = uold.autor,
|
||||||
#kod = uold.kod,
|
kod = uold.kod,
|
||||||
cislo_zadani = uold.cislo_zadani_old,
|
cislo_zadani = uold.cislo_zadani_old,
|
||||||
cislo_reseni = uold.cislo_reseni_old,
|
cislo_reseni = uold.cislo_reseni_old,
|
||||||
max_body = uold.body,
|
max_body = uold.body,
|
||||||
#vytvoreno = uold.vytvoreno,
|
vytvoreno = uold.vytvoreno,
|
||||||
)
|
)
|
||||||
# unew.opravovatele.add(*uold.opravovatele.all())
|
|
||||||
unew.save()
|
unew.save()
|
||||||
|
unew.opravovatele.add(*uold.opravovatele.all())
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
# Nody:
|
# Nody:
|
||||||
zadani_node = UlohaZadaniNode.objects.create(uloha = unew)
|
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))
|
raise ValueError("Různá čísla zadání a řešení u článku! (Článek: {})".format(cl.nazev))
|
||||||
|
|
||||||
clnew = Clanek.objects.create(
|
clnew = Clanek.objects.create(
|
||||||
problem_ptr = cl,
|
problem_ptr_id = cl.id,
|
||||||
# Problém by nemělo být potřeba upravovat
|
# Problém by nemělo být potřeba upravovat
|
||||||
cislo = cislo,
|
cislo = cislo,
|
||||||
# Body ignorujeme, protože už jsou v hodnocení
|
# Body ignorujeme, protože už jsou v hodnocení
|
||||||
|
@ -149,13 +158,13 @@ def tema_to_Tema(apps, schema_editor):
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('seminar', '0057_reseni_to_reseni_hodnoceni'),
|
('seminar', '0087_fix_polymorphism'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
# ashes to Ashes, dust to Dust....
|
# ashes to Ashes, dust to Dust....
|
||||||
migrations.RunPython(uloha_to_Uloha, migrations.RunPython.noop),
|
migrations.RunPython(uloha_to_Uloha, migrations.RunPython.noop),
|
||||||
migrations.RunPython(tema_to_Tema, migrations.RunPython.noop),
|
# migrations.RunPython(tema_to_Tema, migrations.RunPython.noop),
|
||||||
migrations.RunPython(clanek_to_Clanek, migrations.RunPython.noop),
|
# migrations.RunPython(clanek_to_Clanek, migrations.RunPython.noop),
|
||||||
migrations.RunPython(konfery_rucne, migrations.RunPython.noop),
|
# migrations.RunPython(konfery_rucne, migrations.RunPython.noop),
|
||||||
]
|
]
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('contenttypes', '0002_remove_content_type_name'),
|
('contenttypes', '0002_remove_content_type_name'),
|
||||||
('seminar', '0064_auto_20190610_2358'),
|
('seminar', '0057_reseni_to_reseni_hodnoceni'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
31
seminar/migrations/0066b_orgtextnode.py
Normal file
31
seminar/migrations/0066b_orgtextnode.py
Normal file
|
@ -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
Normal file
29
seminar/migrations/0066c_reseninode.py
Normal file
|
@ -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',),
|
||||||
|
),
|
||||||
|
|
||||||
|
]
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('seminar', '0066_problem_polymorphic_ctype'),
|
('seminar', '0064_auto_20190610_2358'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -7,7 +7,7 @@ import django.db.models.deletion
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('seminar', '0076_auto_20200228_2013'),
|
('seminar', '0066c_reseninode'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -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',),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('seminar', '0078_otistenereseninode'),
|
('seminar', '0076_auto_20200228_2013'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -31,28 +31,10 @@ class Migration(migrations.Migration):
|
||||||
model_name='konfera',
|
model_name='konfera',
|
||||||
name='ucastnici',
|
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(
|
migrations.RemoveField(
|
||||||
model_name='konfera',
|
model_name='konfera',
|
||||||
name='id',
|
name='id',
|
||||||
),
|
),
|
||||||
migrations.RenameModel(
|
|
||||||
old_name='OtisteneReseniNode',
|
|
||||||
new_name='ReseniNode',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name='clanek',
|
model_name='clanek',
|
||||||
name='cislo',
|
name='cislo',
|
||||||
|
|
|
@ -41,7 +41,7 @@ def fix_problem(apps, schema_editor):
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('seminar', '0086_auto_20200819_0959'),
|
('seminar', '0077_auto_20200318_2146'),
|
||||||
]
|
]
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(fix_treenode, migrations.RunPython.noop),
|
migrations.RunPython(fix_treenode, migrations.RunPython.noop),
|
||||||
|
|
|
@ -27,7 +27,7 @@ def add_perms(apps, schema_editor):
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('seminar', '0087_fix_polymorphism'),
|
('seminar', '0086_auto_20200819_0959'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
28
seminar/migrations/0093_auto_20210330_2105.py
Normal file
28
seminar/migrations/0093_auto_20210330_2105.py
Normal file
|
@ -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…
Reference in a new issue