Preserve usage provider identity

This commit is contained in:
fawney19
2026-05-20 20:56:36 +08:00
parent c972bbd397
commit 57910f906d
21 changed files with 340 additions and 104 deletions

View File

@@ -0,0 +1,10 @@
-- Usage is a historical fact table. Backfill nullable provider_id snapshots
-- from the unique provider name where the catalog row still exists.
UPDATE `usage` AS usage_rows
JOIN providers
ON providers.name = TRIM(usage_rows.provider_name)
SET usage_rows.provider_id = providers.id
WHERE usage_rows.provider_id IS NULL
AND TRIM(COALESCE(usage_rows.provider_name, '')) <> ''
AND LOWER(TRIM(COALESCE(usage_rows.provider_name, ''))) NOT IN ('unknown', 'unknow', 'pending');