diff --git a/src/main/resources/db/changelog/020-audit-log.sql b/src/main/resources/db/changelog/020-audit-log.sql index 428f1e87..173e5741 100644 --- a/src/main/resources/db/changelog/020-audit-log.sql +++ b/src/main/resources/db/changelog/020-audit-log.sql @@ -53,6 +53,19 @@ create table tx_journal create index on tx_journal (targetTable, targetUuid); --// +-- ============================================================================ +--changeset audit-TX-JOURNAL-VIEW:1 endDelimiter:--// +-- ---------------------------------------------------------------------------- +/* + A view combining tx_journal with tx_context. + */ +create view tx_journal_v as +select txc.*, txj.targettable, txj.targetop, txj.targetuuid, txj.targetdelta + from tx_journal txj + left join tx_context txc using (contextid) + order by txc.txtimestamp; +--// + -- ============================================================================ --changeset audit-TX-JOURNAL-TRIGGER:1 endDelimiter:--// -- ---------------------------------------------------------------------------- diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java index e2f27863..a4fcef18 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java @@ -279,9 +279,8 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_bankaccount'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java index 0308c31d..83078403 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRepositoryIntegrationTest.java @@ -259,9 +259,8 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_contact'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java index 89f48402..e8279f3e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java @@ -216,9 +216,8 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_coopassetstransaction'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java index 78d0ac7d..6b43c94e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java @@ -215,9 +215,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_coopsharestransaction'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java index 2758efa4..e27e4b75 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java @@ -548,10 +548,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId - where targettable = 'hs_office_debitor'; + select currentTask, targetTable, targetOp + from tx_journal_v + where targettable = 'hs_office_coopsharestransaction'; """); // when diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java index af62541c..4acd4907 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java @@ -376,9 +376,8 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_membership'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java index 4ac8abb0..1a5a6258 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java @@ -443,9 +443,8 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_partner'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java index 8d7eace2..fa39751b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java @@ -262,9 +262,8 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_person'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java index 21663db0..5be5fe6b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java @@ -370,9 +370,8 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_relationship'; """); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java index 0ebffd55..ce63e2e8 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java @@ -390,9 +390,8 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTest { public void auditJournalLogIsAvailable() { // given final var query = em.createNativeQuery(""" - select c.currenttask, j.targettable, j.targetop - from tx_journal j - join tx_context c on j.contextId = c.contextId + select currentTask, targetTable, targetOp + from tx_journal_v where targettable = 'hs_office_sepamandate'; """);