Update other related tables

This commit is contained in:
Jan Kvetina 2021-12-26 13:33:52 +01:00
parent ef70a94866
commit e67ccf1d01

View File

@ -38,10 +38,18 @@ COMPOUND TRIGGER
:NEW.updated_at := curr_updated_at;
--
IF UPDATING AND :NEW.user_id != :OLD.user_id THEN
UPDATE user_roles r
SET r.user_id = :NEW.user_id
WHERE r.user_id = :OLD.user_id;
--
UPDATE sessions s
SET s.user_id = :NEW.user_id
WHERE s.user_id = :OLD.user_id;
--
UPDATE logs_events l
SET l.user_id = :NEW.user_id
WHERE l.user_id = :OLD.user_id;
--
curr_event_id := app.log_event('USER_ID_CHANGED');
END IF;
ELSE