-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Migration 0033 failed when empty palceholder objects were not present in the db #8340
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMigration 0033 is updated to avoid failures when placeholder records are absent by adding an explicit guard before updating placeholder references. Flow diagram for updated placeholder migration logic in Migration 0033flowchart TD
A["Iterate over objects"] --> B["Check if placeholder record exists"]
B -->|Exists| C["Update placeholder record with content_type_id and object_id"]
B -->|Does not exist but obj_placeholder_field exists| D["Update obj_placeholder_field with content_type_id and object_id"]
D --> E["Save obj_placeholder_field"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
👋 Hi there! Please remember to MERGE COMMIT pull requests from Do not SQUASH commits to preserve history for the changelog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `cms/migrations/0033_placeholder_source_data_migration.py:42` </location>
<code_context>
object_id=obj.pk,
)
- else:
+ elif obj_placeholder_field:
obj_placeholder_field.content_type_id = cur_ct_obj.pk
obj_placeholder_field.object_id = obj.pk
</code_context>
<issue_to_address>
Switching from 'else' to 'elif obj_placeholder_field' changes the control flow and may affect migration behavior.
Please verify that objects with a falsy 'obj_placeholder_field' do not require updates, as the new logic will skip them. Ensure all necessary cases are still covered.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -39,7 +39,7 @@ def forwards(apps, schema_editor): | |||
content_type_id=cur_ct_obj.pk, | |||
object_id=obj.pk, | |||
) | |||
else: | |||
elif obj_placeholder_field: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Switching from 'else' to 'elif obj_placeholder_field' changes the control flow and may affect migration behavior.
Please verify that objects with a falsy 'obj_placeholder_field' do not require updates, as the new logic will skip them. Ensure all necessary cases are still covered.
…
Description
Related resources
Checklist
main
Summary by Sourcery
Bug Fixes: