-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(aci): Implement DataSource.normalize_before_relocation_import #103002
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
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #103002 +/- ##
===========================================
+ Coverage 80.58% 80.83% +0.24%
===========================================
Files 8937 8950 +13
Lines 391228 392336 +1108
Branches 24887 24887
===========================================
+ Hits 315277 317136 +1859
+ Misses 75581 74830 -751
Partials 370 370 |
| # DataSource.source_id dynamically references different models based on the 'type' field. | ||
| # We declare all possible dependencies here to ensure proper import ordering. |
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.
Does the order matter because we need the pk mappings for the other tables to exist before this table is relocated?
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.
Yes.
| # Referenced model not in pk_map. This may be correct (reset_pks=False) or broken | ||
| # (reset_pks=True but referenced model was filtered out or failed to import). |
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.
Should we return None if we can't map the source_id? I think with this logic it will keep this object mapped to the old source_id, which could be inaccurate?
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.
We should, and now we do. I got confused by test logic, but now know better.
| DataSource.source_id is a dynamic foreign key that gets remapped during import via the | ||
| normalize_before_relocation_import method. Since the remapping is handled there, we just | ||
| need to verify that both sides have a valid source_id value, without comparing the actual values. |
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.
nice
…03002) To be properly imported from backup (as with self-host to saas migration) DataSource needs to remap ids to new values. This involves tracking dependencies and translating in normalize_before_relocation_import. The field comparator has to be somewhat lax here, as the actual foreign item referenced is dependent on two fields, which isn't really a pattern supported by our ForeignKey comparator infrastructure. For now, at least, we assume the fields being referenced are valid (a big improvement over the current prod code, where we have broken id references and also ignore that), but this will be revisited in a follow-up.
To be properly imported from backup (as with self-host to saas migration) DataSource needs to remap ids to new values.
This involves tracking dependencies and translating in normalize_before_relocation_import.
The field comparator has to be somewhat lax here, as the actual foreign item referenced is dependent on two fields, which isn't really a pattern supported by our ForeignKey comparator infrastructure. For now, at least, we assume the fields being referenced are valid (a big improvement over the current prod code, where we have broken id references and also ignore that), but this will be revisited in a follow-up.