You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(backup): Fix query logic for dangling model exports
There are a small number of models that have no unambiguous direct
connection to their relocation scope's root model - these are called
"dangling" models. The key factor that defines them, and makes them
difficult to handle, is that we cannot use our "query already exported
foreign keys" filtering methodology to select only the models relevant
to our export targets, because these models have no foreign keys that
connect them back to the root of that target. For example,
`TimeSeriesSnapshot` has no foreign keys at all, see:
https://tinyurl.com/27z4x6tk.
In cases like the one above, we ended up exporting ALL of the
`TimeSeriesSnapshot`s in the database - clearly a very bad outcome when
we only want to export those related to a specific org! A better
approach is to define custom filtering logic for these models, thereby
enabling them to use "adjacent" models in the model graph to select only
models that we care about for a given export. In the example above, we
query all `Incident`s filtered down by our previous exports to get a
sneak-peek at the set of `IncidentSnapshot`s (a set that is currently
empty due to going in reverse dependency order), then use that
information to work backwards to grab the `TimeSeriesSnapshot`s we need.
The upshot is that this commit introduces a generic method for
constructing filtered queries for a specific model, the overridable
`query_for_relocation_export`.
Issue: getsentry/team-ospo#203
0 commit comments