Skip to content
Snippets Groups Projects
Verified Commit f10cd3ab authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Create migration checking for old data requiring Lesrooster to be installed

parent 8a757f6a
No related branches found
No related tags found
1 merge request!396Migration path to new models
from django.db import migrations, models
from django.apps import apps as global_apps
def check_for_migration(apps, schema_editor):
if global_apps.is_installed('aleksis.apps.lesrooster'):
return
ExcuseType = apps.get_model('alsijil', 'ExcuseType')
PersonalNote = apps.get_model('alsijil', 'PersonalNote')
LessonDocumentation = apps.get_model('alsijil', 'LessonDocumentation')
model_types = [ExcuseType, PersonalNote, LessonDocumentation]
for model in model_types:
if model.objects.exists():
raise RuntimeError("You have legacy data. Please install AlekSIS-App-Lesrooster to migrate them.")
class Migration(migrations.Migration):
dependencies = [
('alsijil', '0023_add_tardiness_and_rework_constraints'),
]
operations = [
migrations.RunPython(check_for_migration),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment