diff --git a/aleksis/apps/alsijil/migrations/0024_check_new_models.py b/aleksis/apps/alsijil/migrations/0024_check_new_models.py new file mode 100644 index 0000000000000000000000000000000000000000..da52a87226e6591939b5888c37667ea79ab7f47f --- /dev/null +++ b/aleksis/apps/alsijil/migrations/0024_check_new_models.py @@ -0,0 +1,27 @@ +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), + ]