feat(spanner): Add pre-delete hook for data migration#1751
Merged
jcscottiii merged 1 commit intomainfrom Aug 25, 2025
Merged
Conversation
Base automatically changed from
jcscottiii/refactor-insert-web-features
to
main
August 22, 2025 20:16
5906611 to
2f97f8a
Compare
Introduces a pre-delete hook to the generic entity synchronizer to allow for data migration before an entity is deleted. This is necessary when a feature is moved or renamed, which is represented as a deletion of the old feature key. Previously, when a web feature's key was changed in the source repository (e.g., `feature-a` becomes `feature-b`), the sync process would see this as a deletion of `feature-a` and an creation of `feature-b`. This resulted in the loss of all associated historical data, such as WPT and UMA metrics, that were linked to the old feature's ID. This change addresses the problem by: 1. Introducing a `PreDeleteHook` to the `syncableEntityMapper` interface. 2. Implementing this hook for the `webFeatureSpannerMapper` to migrate associated data (WPT metrics, UMA metrics, etc.) from a redirected feature to its new target before the old feature is deleted. 3. Reordering the sync operation to perform upserts before deletes, ensuring the target feature exists before the source is removed. 4. Adding an integration test to verify that data is correctly migrated when a feature is redirected. This prevents data loss when features are renamed or moved, ensuring the continuity of historical metrics.
2f97f8a to
df036ec
Compare
jrobbins
approved these changes
Aug 25, 2025
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduces a pre-delete hook to the generic entity synchronizer to allow for data migration before an entity is deleted. This is necessary when a feature is moved or renamed, which is represented as a deletion of the old feature key.
Previously, when a web feature's key was changed in the source repository (e.g.,
feature-abecomesfeature-b), the sync process would see this as a deletion offeature-aand an creation offeature-b. This resulted in the loss of all associated historical data, such as WPT and UMA metrics, that were linked to the old feature's ID.This change addresses the problem by:
PreDeleteHookto thesyncableEntityMapperinterface.webFeatureSpannerMapperto migrate associated data (WPT metrics, UMA metrics, etc.) from a redirected feature to its new target before the old feature is deleted.This prevents data loss when features are renamed or moved, ensuring the continuity of historical metrics.
A future PR will be landed to ensure that this connection continues until upstream sources are fixed.