unified-storage: make sql backend update key_path for kv store (#114879)

* unified-storage: update resource_history_update_rv.sql to populate key_path in resource_history
This commit is contained in:
Will Assis
2025-12-10 07:06:06 -05:00
committed by GitHub
parent 532a2e5f4d
commit 755b479be4
9 changed files with 346 additions and 9 deletions
@@ -5,6 +5,25 @@ SET {{ .Ident "resource_version" }} = (
WHEN {{ $.Ident "guid" }} = {{ $.Arg $guid }} THEN CAST({{ $.Arg $rv }} AS {{ if eq $.DialectName "postgres" }}BIGINT{{ else }}SIGNED{{ end }})
{{ end }}
END
), {{ .Ident "key_path" }} = (
CASE
{{ range $guid, $snowflakeRv := .GUIDToSnowflakeRV }}
WHEN {{ $.Ident "guid" }} = {{ $.Arg $guid }} THEN CONCAT(
'unified', {{ $.SlashFunc }}, 'data', {{ $.SlashFunc }},
{{ $.Ident "group" }}, {{ $.SlashFunc }},
{{ $.Ident "resource" }}, {{ $.SlashFunc }},
{{ $.Ident "namespace" }}, {{ $.SlashFunc }},
{{ $.Ident "name" }}, {{ $.SlashFunc }},
CAST({{ $.Arg $snowflakeRv }} AS {{ if eq $.DialectName "postgres" }}BIGINT{{ else }}SIGNED{{ end }}),
{{ $.TildeFunc }},
CASE {{ $.Ident "action" }}
WHEN 1 THEN 'created'
WHEN 2 THEN 'updated'
WHEN 3 THEN 'deleted'
END, {{ $.TildeFunc }},
COALESCE({{ $.Ident "folder" }}, ''))
{{ end }}
END
)
WHERE {{ .Ident "guid" }} IN (
{{$first := true}}