From 756847c86398220ee53f430a3820ed28bd9af26d Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Tue, 3 Oct 2023 12:19:05 -0400 Subject: [PATCH] Fix reset labels for dynamic grouped labels Another cases where the code is expecting all labels to be unique on name. Closes #402 --- bootstrap/004_labels.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bootstrap/004_labels.sql b/bootstrap/004_labels.sql index 7166a1b7..f636c0e9 100644 --- a/bootstrap/004_labels.sql +++ b/bootstrap/004_labels.sql @@ -307,7 +307,13 @@ LANGUAGE SQL EXECUTE AS OWNER AS $$ - insert into internal.labels ("NAME", "GROUP_NAME", "GROUP_RANK", "LABEL_CREATED_AT", "CONDITION", "LABEL_MODIFIED_AT", "IS_DYNAMIC") select name, group_name, group_rank, label_created_at, condition, label_modified_at, IS_DYNAMIC from internal.predefined_labels where name not in (select name from internal.labels); + insert into internal.labels ("NAME", "GROUP_NAME", "GROUP_RANK", "LABEL_CREATED_AT", "CONDITION", "LABEL_MODIFIED_AT", "IS_DYNAMIC") + select name, group_name, group_rank, label_created_at, condition, label_modified_at, IS_DYNAMIC from internal.predefined_labels + where not is_dynamic and name not in (select name from internal.labels); + -- dynamic labels are unique by group_name not name + insert into internal.labels ("NAME", "GROUP_NAME", "GROUP_RANK", "LABEL_CREATED_AT", "CONDITION", "LABEL_MODIFIED_AT", "IS_DYNAMIC") + select name, group_name, group_rank, label_created_at, condition, label_modified_at, IS_DYNAMIC from internal.predefined_labels + where is_dynamic and group_name not in (select group_name from internal.labels where is_dynamic); $$; CREATE OR REPLACE PROCEDURE INTERNAL.MIGRATE_PREDEFINED_LABELS(gap_in_seconds NUMBER)