feat(unified-storage): prune history table based on limits (#101970)
This commit is contained in:
committed by
GitHub
parent
cacdf00067
commit
1700a8aa9f
@@ -0,0 +1,22 @@
|
||||
DELETE FROM {{ .Ident "resource_history" }}
|
||||
WHERE {{ .Ident "guid" }} IN (
|
||||
SELECT {{ .Ident "guid" }}
|
||||
FROM (
|
||||
SELECT
|
||||
{{ .Ident "guid" }},
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY
|
||||
{{ .Ident "namespace" }},
|
||||
{{ .Ident "group" }},
|
||||
{{ .Ident "resource" }},
|
||||
{{ .Ident "name" }}
|
||||
ORDER BY {{ .Ident "resource_version" }} DESC
|
||||
) AS {{ .Ident "rn" }}
|
||||
FROM {{ .Ident "resource_history" }}
|
||||
WHERE
|
||||
{{ .Ident "namespace" }} = {{ .Arg .Key.Namespace }}
|
||||
AND {{ .Ident "group" }} = {{ .Arg .Key.Group }}
|
||||
AND {{ .Ident "resource" }} = {{ .Arg .Key.Resource }}
|
||||
) AS {{ .Ident "ranked" }}
|
||||
WHERE {{ .Ident "rn" }} > {{ .Arg .HistoryLimit }}
|
||||
);
|
||||
Reference in New Issue
Block a user