Skip to content

Commit

Permalink
fix: handle first observed migration change (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored Aug 22, 2024
1 parent 9249cd9 commit b5d1617
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions functions/pre_alter_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BEGIN
-- Check if the column "count" exists in the "config_changes" table
IF EXISTS (
SELECT 1
FROM information_schema.columns
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'config_changes'
AND column_name = 'count'
Expand All @@ -15,12 +15,29 @@ BEGIN
END IF;
END $$;

DO $$
BEGIN
-- Check if the column "first_observed" exists in the "config_changes" table
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'config_changes'
AND column_name = 'first_observed'
) THEN
-- Update existing NULL values in the "first_observed" column
UPDATE config_changes
SET first_observed = NOW()
WHERE first_observed IS NULL;
END IF;
END $$;

DO $$
BEGIN
-- Check if the column "category" exists in the "playbooks" table
IF EXISTS (
SELECT 1
FROM information_schema.columns
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'playbooks'
AND column_name = 'category'
Expand Down

0 comments on commit b5d1617

Please sign in to comment.