diff --git a/src/main/resources/config/liquibase/changelog/constraints_UserRoleAssignment.xml b/src/main/resources/config/liquibase/changelog/constraints_UserRoleAssignment.xml new file mode 100644 index 00000000..66a7712f --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/constraints_UserRoleAssignment.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/historicization/historicization_UserRoleAssignment.xml b/src/main/resources/config/liquibase/historicization/historicization_UserRoleAssignment.xml new file mode 100644 index 00000000..e5f3c9f4 --- /dev/null +++ b/src/main/resources/config/liquibase/historicization/historicization_UserRoleAssignment.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CREATE TRIGGER user_role_assignment_historicize + AFTER INSERT OR DELETE OR UPDATE ON user_role_assignment + FOR EACH ROW EXECUTE PROCEDURE historicize(); + + + DROP TRIGGER user_role_assignment_historicize + + + + + + SELECT * + FROM user_role_assignment_history + WHERE history_id IN ( + SELECT max(history_id) AS history_id + FROM user_role_assignment_history + WHERE history_transaction <= current_setting('history.transaction')::bigint + GROUP BY entity_type_id, entity_object_id, assigned_role, user_id) -- must have a unique constraint + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index a81ec0b8..1a649f66 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -23,10 +23,12 @@ + +