ref(backup): Move relocation logic into models#55065
Merged
Merged
Conversation
Contributor
Author
|
@corps This PR is still in draft mode because its on top of a stack which is blocked on a getsentry merge (hence those tests failing), but it is otherwise ready for review. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #55065 +/- ##
==========================================
- Coverage 79.98% 79.98% -0.01%
==========================================
Files 5037 5037
Lines 214727 214717 -10
Branches 36477 36462 -15
==========================================
- Hits 171753 171740 -13
- Misses 37695 37703 +8
+ Partials 5279 5274 -5
|
43a3961 to
d1feaf1
Compare
Base automatically changed from
azaslavsky/backup/relocation_scope_in_dependencies
to
master
August 18, 2023 22:38
0eab32a to
3779534
Compare
corps
approved these changes
Aug 28, 2023
f6dd2cd to
224ca0a
Compare
224ca0a to
4f94278
Compare
We've accumulated a decent number of special cases for how we do relocation, what with Actors and Teams having circular dependencies, Users auto-creating their UserEmails, the need to sanitize out dangerous models like UserPermissions, etc, etc, etc. This is a simple refactoring change that uses a roughly "typeclass"-ish pattern: we define two new methods on `BaseModel`, `_normalize_before_relocation_import` to transform the data (no transform by default) and `write_relocation_import` to actually save it to the database. Downstream models that need special logic at either of these stages are then free overwrite one or both of these steps as they please. The main benefit of this approach is that this logic lives closer to the models it affects, rather than in some farflung section of the codebase. When we make changes to them in the future, relocation logic will be right there, encouraging folks to remember to change how that works (if necessary) as well.
4f94278 to
9abb7c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We've accumulated a decent number of special cases for how we do relocation, what with Actors and Teams having circular dependencies, Users auto-creating their UserEmails, the need to sanitize out dangerous models like UserPermissions, etc, etc, etc.
This is a simple refactoring change that uses a roughly "typeclass"-ish pattern: we define two new methods on
BaseModel,_normalize_before_relocation_importto transform the data (no transform by default) andwrite_relocation_importto actually save it to the database. Downstream models that need special logic at either of these stages are then free overwrite one or both of these steps as they please.The main benefit of this approach is that this logic lives closer to the models it affects, rather than in some farflung section of the codebase. When we make changes to them in the future, relocation logic will be right there, encouraging folks to remember to change how that works (if necessary) as well.