Skip to content

Commit

Permalink
chore: fix playbook dup migration
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Aug 16, 2024
1 parent 1bcd1dd commit 79aa374
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions views/032_playbook_nulls.sql
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
UPDATE playbooks set category = '' WHERE category IS NULL;
WITH duplicates AS (
SELECT
name,
namespace,
category,
ROW_NUMBER() OVER (PARTITION BY name, namespace, category ORDER BY id) as row_num
FROM playbooks
)
UPDATE playbooks
SET name = playbooks.name || '_' || right(id::text, 4)
FROM duplicates
WHERE playbooks.name = duplicates.name
AND playbooks.namespace = duplicates.namespace
AND playbooks.category = duplicates.category
AND duplicates.row_num > 1;

0 comments on commit 79aa374

Please sign in to comment.