Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migration 0045: update all new fields #1900

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def migrate_models(self) -> Optional[List[BaseRequestEvent]]:
for replacement in model.get(self.old_field, []):
structured_field = self.old_field.replace("$", f"${replacement}")
update[structured_field] = None
if structured_value := model.get(structured_field):
update[self.new_field][replacement] = structured_value
update[self.new_field][replacement] = model.get(structured_field)
events.append(
RequestUpdateEvent(
fqid_from_collection_and_id("motion", id), update
Expand Down
8 changes: 4 additions & 4 deletions tests/system/migrations/test_0045_fix_amendment_paragraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def test_migration(write, finalize, assert_model):
"id": 61,
"amendment_paragraph_$": ["0", "1", "2", "42"],
"amendment_paragraph_$0": "change",
"amendment_paragraph_$1": "change",
"amendment_paragraph_$2": "change",
"amendment_paragraph_$1": "",
"amendment_paragraph_$2": "",
"amendment_paragraph_$42": "change",
},
},
Expand All @@ -29,8 +29,8 @@ def test_migration(write, finalize, assert_model):
"id": 61,
"amendment_paragraphs": {
"0": "change",
"1": "change",
"2": "change",
"1": "",
"2": "",
"42": "change",
},
},
Expand Down