Skip to content

feat(spanner): Add pre-delete hook for data migration#1751

Merged
jcscottiii merged 1 commit intomainfrom
jcscottiii/delete-prehook
Aug 25, 2025
Merged

feat(spanner): Add pre-delete hook for data migration#1751
jcscottiii merged 1 commit intomainfrom
jcscottiii/delete-prehook

Conversation

@jcscottiii
Copy link
Collaborator

@jcscottiii jcscottiii commented Aug 21, 2025

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.

A future PR will be landed to ensure that this connection continues until upstream sources are fixed.

Base automatically changed from jcscottiii/refactor-insert-web-features to main August 22, 2025 20:16
@jcscottiii jcscottiii force-pushed the jcscottiii/delete-prehook branch 3 times, most recently from 5906611 to 2f97f8a Compare August 24, 2025 15:44
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.
@jcscottiii jcscottiii changed the title feat: Introduce pre delete hook feat(spanner): Add pre-delete hook for data migration Aug 24, 2025
@jcscottiii jcscottiii force-pushed the jcscottiii/delete-prehook branch from 2f97f8a to df036ec Compare August 24, 2025 21:46
@jcscottiii jcscottiii marked this pull request as ready for review August 25, 2025 13:26
@jcscottiii jcscottiii requested a review from jrobbins August 25, 2025 13:26
@jcscottiii jcscottiii added this pull request to the merge queue Aug 25, 2025
Merged via the queue into main with commit 830e31d Aug 25, 2025
7 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/delete-prehook branch August 25, 2025 17:38
@jstenback jstenback mentioned this pull request Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants