Unistore: Add generation column (#102222)
This commit is contained in:
@@ -10,6 +10,7 @@ INSERT INTO {{ .Ident "resource_history" }}
|
||||
{{ .Ident "resource_version" }},
|
||||
{{ end }}
|
||||
{{ .Ident "previous_resource_version"}},
|
||||
{{ .Ident "generation"}},
|
||||
{{ .Ident "value" }},
|
||||
{{ .Ident "action" }}
|
||||
)
|
||||
@@ -25,6 +26,7 @@ INSERT INTO {{ .Ident "resource_history" }}
|
||||
{{ .Arg .ResourceVersion }},
|
||||
{{ end }}
|
||||
{{ .Arg .WriteEvent.PreviousRV }},
|
||||
{{ .Arg .Generation }},
|
||||
{{ .Arg .WriteEvent.Value }},
|
||||
{{ .Arg .WriteEvent.Type }}
|
||||
)
|
||||
|
||||
@@ -5,19 +5,23 @@ WHERE {{ .Ident "guid" }} IN (
|
||||
SELECT
|
||||
{{ .Ident "guid" }},
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY
|
||||
{{ .Ident "namespace" }},
|
||||
{{ .Ident "group" }},
|
||||
{{ .Ident "resource" }},
|
||||
{{ .Ident "name" }}
|
||||
PARTITION BY {{ .Ident "namespace" }}
|
||||
, {{ .Ident "group" }}
|
||||
, {{ .Ident "resource" }}
|
||||
, {{ .Ident "name" }}
|
||||
{{ if .PartitionByGeneration }}
|
||||
, {{ .Ident "generation" }}
|
||||
{{ end }}
|
||||
ORDER BY {{ .Ident "resource_version" }} DESC
|
||||
) AS {{ .Ident "rn" }}
|
||||
FROM {{ .Ident "resource_history" }}
|
||||
WHERE
|
||||
{{ .Ident "namespace" }} = {{ .Arg .Key.Namespace }}
|
||||
WHERE {{ .Ident "namespace" }} = {{ .Arg .Key.Namespace }}
|
||||
AND {{ .Ident "group" }} = {{ .Arg .Key.Group }}
|
||||
AND {{ .Ident "resource" }} = {{ .Arg .Key.Resource }}
|
||||
AND {{ .Ident "name" }} = {{ .Arg .Key.Name }}
|
||||
{{ if .PartitionByGeneration }}
|
||||
AND {{ .Ident "generation" }} > 0
|
||||
{{ end }}
|
||||
) AS {{ .Ident "ranked" }}
|
||||
WHERE {{ .Ident "rn" }} > {{ .Arg .HistoryLimit }}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user