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

feat(backup): Enable shimming deleted fields #66248

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

azaslavsky
Copy link
Contributor

We need to support deleted fields on Django model schemas for a number of self-hosted released (currently 2). This means that even if we delete a field on HEAD, we still need to make the import script aware that the field could exit on imported JSON, and pre-process that JSON in such a way that the field is removed in cases where the JSON was generated by an old version that still contained the field.

There is no purpose in testing this code standalone. It passes tests in #65923, which is the first actual use of this shimming mechanism.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 4, 2024
@azaslavsky azaslavsky requested a review from hubertdeng123 March 4, 2024 20:55
We need to support deleted fields on Django model schemas for a number
of self-hosted released (currently 2). This means that even if we delete
a field on HEAD, we still need to make the import script aware that the
field could exit on imported JSON, and pre-process that JSON in such a
way that the field is removed in cases where the JSON was generated by
an old version that still contained the field.

There is no purpose in testing this code standalone. It passes tests in
 #65923, which is the first actual use of this shimming mechanism.
@azaslavsky azaslavsky force-pushed the az/add-deleted-field-shimming-dict branch from d829ac9 to 40cc7a0 Compare March 4, 2024 20:59
@azaslavsky azaslavsky marked this pull request as ready for review March 4, 2024 21:01
@azaslavsky azaslavsky requested a review from a team March 4, 2024 21:01
# around even if the dict is empty, to ensure that there is a ready place to pop shims into. For
# each entry in this dict, please leave a TODO comment pointed to a github issue for removing
# the shim, noting in the comment which self-hosted release will trigger the removal.
deleted_fields: dict[str, set[str]] = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is deleted_fields being updated over time to store all the deleted fields? If so, would it be better to place this as a global variable at the top of the file or somewhere more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 84.27%. Comparing base (3ab3d14) to head (da58c0e).
Report is 29 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #66248   +/-   ##
=======================================
  Coverage   84.27%   84.27%           
=======================================
  Files        5304     5304           
  Lines      237049   237058    +9     
  Branches    41024    41030    +6     
=======================================
+ Hits       199768   199779   +11     
+ Misses      37062    37060    -2     
  Partials      219      219           
Files Coverage Δ
src/sentry/backup/imports.py 93.62% <20.00%> (-3.80%) ⬇️

... and 21 files with indirect coverage changes

@azaslavsky azaslavsky merged commit 495179a into master Mar 4, 2024
48 of 49 checks passed
@azaslavsky azaslavsky deleted the az/add-deleted-field-shimming-dict branch March 4, 2024 23:44
aliu39 pushed a commit that referenced this pull request Mar 6, 2024
We need to support deleted fields on Django model schemas for a number
of self-hosted released (currently 2). This means that even if we delete
a field on HEAD, we still need to make the import script aware that the
field could exit on imported JSON, and pre-process that JSON in such a
way that the field is removed in cases where the JSON was generated by
an old version that still contained the field.

There is no purpose in testing this code standalone. It passes tests in
#65923, which is the first actual use of this shimming mechanism.
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants