From 354cfbbebc3fdf6ff7082e1cc7db0abc147ced78 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 25 May 2019 16:10:50 +0200 Subject: [PATCH] historicization of JHI_USER table --- README.md | 2 +- .../historicization/historicization_User.xml | 98 +++++++++++++++++++ .../resources/config/liquibase/master.xml | 9 +- 3 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/config/liquibase/historicization/historicization_User.xml diff --git a/README.md b/README.md index 19a77f52..f7ab026e 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Then start the application with the pgsql profile: gw bootRun -Ppgsql gw bootRun -Ppgsql -Psample-data # populated with sample data -To use a **remote Postgres database** on a hostsharing server, +To use a **remote Postgres database** on a Hostsharing server, autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" \ -f -N -L 55432:127.0.0.1:5432 "xyz00@xyz.hostsharing.net" diff --git a/src/main/resources/config/liquibase/historicization/historicization_User.xml b/src/main/resources/config/liquibase/historicization/historicization_User.xml new file mode 100644 index 00000000..7a8ffb63 --- /dev/null +++ b/src/main/resources/config/liquibase/historicization/historicization_User.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CREATE TRIGGER jhi_user_historicize + AFTER INSERT OR DELETE OR UPDATE ON jhi_user + FOR EACH ROW EXECUTE PROCEDURE historicize(); + + + DROP TRIGGER jhi_user_historicize + + + + + + SELECT * + FROM jhi_user_history + WHERE history_id IN ( + SELECT max(history_id) AS history_id + FROM jhi_user_history + WHERE history_transaction <= current_setting('history.transaction')::bigint + GROUP BY login) -- must have a unique constraint + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 8f6076ce..9c0f7345 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -7,7 +7,11 @@ - + + + + + @@ -32,8 +36,7 @@ - - +