Skip to content

Commit

Permalink
Fix reset labels for dynamic grouped labels
Browse files Browse the repository at this point in the history
Another cases where the code is expecting all labels to be unique on
name.

Closes sundeck-io#402
  • Loading branch information
joshelser committed Oct 3, 2023
1 parent 9d9a9f0 commit 756847c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bootstrap/004_labels.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 756847c

Please sign in to comment.