Skip to content

Commit

Permalink
feat: connection before update trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Sep 10, 2024
1 parent 82a6d64 commit 9a4adb3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions views/027_connections.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,28 @@ CREATE OR REPLACE VIEW connection_details AS
deleted_at IS NULL
ORDER BY
created_at;

--
CREATE OR REPLACE FUNCTION connection_before_update()
RETURNS TRIGGER AS $$
BEGIN
IF NEW.username = '***' THEN
NEW.username = OLD.username;
END IF;

IF NEW.password = '***' THEN
NEW.password = OLD.password;
END IF;

IF NEW.certificate = '***' THEN
NEW.certificate = OLD.certificate;
END IF;

RETURN NEW;
END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER connection_before_update
BEFORE UPDATE ON connections
FOR EACH ROW EXECUTE PROCEDURE connection_before_update();

0 comments on commit 9a4adb3

Please sign in to comment.