From 491ae22e54c7ef8186d71ed96a4d3fdc457ee288 Mon Sep 17 00:00:00 2001 From: peb-adr Date: Mon, 23 Sep 2024 20:03:02 +0200 Subject: [PATCH] [Cherry-Pick] Fix migration 54 (#2630) (#2638) Co-authored-by: luisa-beerboom <101706784+luisa-beerboom@users.noreply.github.com> --- .../migrations/migrations/0054_split_mediafile_model.py | 3 ++- tests/system/migrations/test_0054_split_mediafile_model.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openslides_backend/migrations/migrations/0054_split_mediafile_model.py b/openslides_backend/migrations/migrations/0054_split_mediafile_model.py index f06958ec7..f356d2d51 100644 --- a/openslides_backend/migrations/migrations/0054_split_mediafile_model.py +++ b/openslides_backend/migrations/migrations/0054_split_mediafile_model.py @@ -114,7 +114,8 @@ def migrate_models(self) -> list[BaseRequestEvent] | None: ) for id_, model in models.items(): if ( - collection_from_fqid(fqid := model["content_object_id"]) + model.get("content_object_id") + and collection_from_fqid(fqid := model["content_object_id"]) == "mediafile" ): events.append( diff --git a/tests/system/migrations/test_0054_split_mediafile_model.py b/tests/system/migrations/test_0054_split_mediafile_model.py index 3ba25dea7..2507cbf72 100644 --- a/tests/system/migrations/test_0054_split_mediafile_model.py +++ b/tests/system/migrations/test_0054_split_mediafile_model.py @@ -145,6 +145,11 @@ def test_migration(write, finalize, assert_model): "fqid": "projection/1", "fields": {"id": 1, "meeting_id": 2, "content_object_id": "mediafile/5"}, }, + { + "type": "create", + "fqid": "projection/2", + "fields": {"id": 2, "meeting_id": 2, "content_object_id": None}, + }, { "type": "create", "fqid": "mediafile/6",