Skip to content

Commit

Permalink
fix: config change update trigger
Browse files Browse the repository at this point in the history
we were reseting the created_at time of config changes everytime
  • Loading branch information
adityathebe committed Sep 11, 2024
1 parent 3b34799 commit a662432
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions views/030_config_changes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ BEGIN
WHEN NEW.details IS DISTINCT FROM OLD.details THEN NEW.count
ELSE count
END,
created_at = NOW(),
created_at = CASE
WHEN NEW.details IS DISTINCT FROM OLD.details THEN NOW()
ELSE COALESCE(NEW.created_at, OLD.created_at)
END,
created_by = NEW.created_by,
details = NEW.details,
is_pushed = NEW.is_pushed,
diff = NEW.diff,
external_created_by = NEW.external_created_by,
external_change_id = NEW.external_change_id,
first_observed = LEAST(first_observed, created_at),
patches = NEW.patches,
severity = NEW.severity,
source = NEW.source,
Expand All @@ -40,12 +42,14 @@ EXCEPTION
WHEN NEW.details IS DISTINCT FROM OLD.details THEN config_changes.count + count_increment
ELSE count
END,
created_at = NOW(),
created_at = CASE
WHEN NEW.details IS DISTINCT FROM OLD.details THEN NOW()
ELSE COALESCE(NEW.created_at, OLD.created_at)
END,
created_by = NEW.created_by,
details = NEW.details,
diff = NEW.diff,
external_created_by = NEW.external_created_by,
first_observed = LEAST(first_observed, created_at),
patches = NEW.patches,
severity = NEW.severity,
source = NEW.source,
Expand Down

0 comments on commit a662432

Please sign in to comment.