introduce separate database-schema for hs-office and amend generators - tests green
This commit is contained in:
parent
fc5bd38288
commit
210e29bc82
@ -213,7 +213,7 @@ public class InsertTriggerGenerator {
|
|||||||
if (g.getSuperRoleDef().isGlobal(GUEST)) {
|
if (g.getSuperRoleDef().isGlobal(GUEST)) {
|
||||||
plPgSql.writeLn(
|
plPgSql.writeLn(
|
||||||
"""
|
"""
|
||||||
-- check INSERT INSERT permission for rbac.global anyone
|
-- check INSERT permission for rbac.global anyone
|
||||||
if ${caseCondition}true then
|
if ${caseCondition}true then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
@ -222,7 +222,7 @@ public class InsertTriggerGenerator {
|
|||||||
} else if (g.getSuperRoleDef().isGlobal(ADMIN)) {
|
} else if (g.getSuperRoleDef().isGlobal(ADMIN)) {
|
||||||
plPgSql.writeLn(
|
plPgSql.writeLn(
|
||||||
"""
|
"""
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if ${caseCondition}rbac.isGlobalAdmin() then
|
if ${caseCondition}rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -384,7 +384,7 @@ create index on rbac.permission (objectUuid, op);
|
|||||||
create index on rbac.permission (opTableName, op);
|
create index on rbac.permission (opTableName, op);
|
||||||
|
|
||||||
ALTER TABLE rbac.permission
|
ALTER TABLE rbac.permission
|
||||||
ADD CONSTRAINT RbacPermission_uc UNIQUE NULLS NOT DISTINCT (objectUuid, op, opTableName);
|
ADD CONSTRAINT unique_including_null_values UNIQUE NULLS NOT DISTINCT (objectUuid, op, opTableName);
|
||||||
|
|
||||||
call base.create_journal('rbac.permission');
|
call base.create_journal('rbac.permission');
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ create or replace function rbactest.customer_insert_permission_check_tf()
|
|||||||
declare
|
declare
|
||||||
superObjectUuid uuid;
|
superObjectUuid uuid;
|
||||||
begin
|
begin
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if rbac.isGlobalAdmin() then
|
if rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -48,7 +48,7 @@ create table hs_office.partner
|
|||||||
/**
|
/**
|
||||||
Trigger function to delete related details of a partner to delete.
|
Trigger function to delete related details of a partner to delete.
|
||||||
*/
|
*/
|
||||||
create or replace function deleteHsOfficeDependentsOnPartnerDelete()
|
create or replace function hs_office.partner_delete_dependents_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language PLPGSQL
|
language PLPGSQL
|
||||||
as $$
|
as $$
|
||||||
@ -73,11 +73,11 @@ end; $$;
|
|||||||
/**
|
/**
|
||||||
Triggers deletion of related rows of a partner to delete.
|
Triggers deletion of related rows of a partner to delete.
|
||||||
*/
|
*/
|
||||||
create trigger hs_office.partner_delete_dependents_trigger
|
create trigger delete_dependents_tg
|
||||||
after delete
|
after delete
|
||||||
on hs_office.partner
|
on hs_office.partner
|
||||||
for each row
|
for each row
|
||||||
execute procedure deleteHsOfficeDependentsOnPartnerDelete();
|
execute procedure hs_office.partner_delete_dependents_tf();
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset michael.hoennig:hs-office-partner-MAIN-TABLE-JOURNAL endDelimiter:--//
|
--changeset michael.hoennig:hs-office-partner-MAIN-TABLE-JOURNAL endDelimiter:--//
|
||||||
|
@ -214,7 +214,7 @@ create or replace function hs_office.partner_insert_permission_check_tf()
|
|||||||
declare
|
declare
|
||||||
superObjectUuid uuid;
|
superObjectUuid uuid;
|
||||||
begin
|
begin
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if rbac.isGlobalAdmin() then
|
if rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -118,7 +118,7 @@ create or replace function hs_office.partner_details_insert_permission_check_tf(
|
|||||||
declare
|
declare
|
||||||
superObjectUuid uuid;
|
superObjectUuid uuid;
|
||||||
begin
|
begin
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if rbac.isGlobalAdmin() then
|
if rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -29,9 +29,9 @@ create table hs_office.debitor
|
|||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Trigger function to delete related rows of a debitor to delete.
|
Trigger function to delete related relations of a debitor to delete.
|
||||||
*/
|
*/
|
||||||
create or replace function deleteHsOfficeDependentsOnDebitorDelete()
|
create or replace function hs_office.debitor_delete_dependents_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language PLPGSQL
|
language PLPGSQL
|
||||||
as $$
|
as $$
|
||||||
@ -50,11 +50,11 @@ end; $$;
|
|||||||
/**
|
/**
|
||||||
Triggers deletion of related details of a debitor to delete.
|
Triggers deletion of related details of a debitor to delete.
|
||||||
*/
|
*/
|
||||||
create trigger hs_office.debitor_delete_dependents_trigger
|
create trigger debitor_delete_dependents_tg
|
||||||
after delete
|
after delete
|
||||||
on hs_office.debitor
|
on hs_office.debitor
|
||||||
for each row
|
for each row
|
||||||
execute procedure deleteHsOfficeDependentsOnDebitorDelete();
|
execute procedure hs_office.debitor_delete_dependents_tf();
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
@ -187,7 +187,7 @@ create or replace function hs_office.debitor_insert_permission_check_tf()
|
|||||||
declare
|
declare
|
||||||
superObjectUuid uuid;
|
superObjectUuid uuid;
|
||||||
begin
|
begin
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if rbac.isGlobalAdmin() then
|
if rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -149,7 +149,7 @@ create or replace function hs_office.membership_insert_permission_check_tf()
|
|||||||
declare
|
declare
|
||||||
superObjectUuid uuid;
|
superObjectUuid uuid;
|
||||||
begin
|
begin
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if rbac.isGlobalAdmin() then
|
if rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -27,7 +27,7 @@ create table if not exists hs_office.coopsharestransaction
|
|||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
alter table hs_office.coopsharestransaction
|
alter table hs_office.coopsharestransaction
|
||||||
add constraint hs_office.coopsharestransaction_reverse_entry_missing
|
add constraint reverse_entry_missing
|
||||||
check ( transactionType = 'ADJUSTMENT' and adjustedShareTxUuid is not null
|
check ( transactionType = 'ADJUSTMENT' and adjustedShareTxUuid is not null
|
||||||
or transactionType <> 'ADJUSTMENT' and adjustedShareTxUuid is null);
|
or transactionType <> 'ADJUSTMENT' and adjustedShareTxUuid is null);
|
||||||
--//
|
--//
|
||||||
@ -55,7 +55,7 @@ begin
|
|||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
alter table hs_office.coopsharestransaction
|
alter table hs_office.coopsharestransaction
|
||||||
add constraint hs_office.coopshares_positive
|
add constraint check_positive_total_shares_count
|
||||||
check ( checkSharesByMembershipUuid(membershipUuid, shareCount) );
|
check ( checkSharesByMembershipUuid(membershipUuid, shareCount) );
|
||||||
|
|
||||||
--//
|
--//
|
||||||
|
@ -35,7 +35,7 @@ create table if not exists hs_office.coopassetstransaction
|
|||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
alter table hs_office.coopassetstransaction
|
alter table hs_office.coopassetstransaction
|
||||||
add constraint hs_office.coopassetstransaction_reverse_entry_missing
|
add constraint reverse_entry_missing
|
||||||
check ( transactionType = 'ADJUSTMENT' and adjustedAssetTxUuid is not null
|
check ( transactionType = 'ADJUSTMENT' and adjustedAssetTxUuid is not null
|
||||||
or transactionType <> 'ADJUSTMENT' and adjustedAssetTxUuid is null);
|
or transactionType <> 'ADJUSTMENT' and adjustedAssetTxUuid is null);
|
||||||
--//
|
--//
|
||||||
@ -63,7 +63,7 @@ begin
|
|||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
alter table hs_office.coopassetstransaction
|
alter table hs_office.coopassetstransaction
|
||||||
add constraint hs_office.coopassets_positive
|
add constraint check_positive_total
|
||||||
check ( checkAssetsByMembershipUuid(membershipUuid, assetValue) );
|
check ( checkAssetsByMembershipUuid(membershipUuid, assetValue) );
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ create or replace function hs_booking_item_insert_permission_check_tf()
|
|||||||
declare
|
declare
|
||||||
superObjectUuid uuid;
|
superObjectUuid uuid;
|
||||||
begin
|
begin
|
||||||
-- check INSERT INSERT if rbac.global ADMIN
|
-- check INSERT permission if rbac.global ADMIN
|
||||||
if rbac.isGlobalAdmin() then
|
if rbac.isGlobalAdmin() then
|
||||||
return NEW;
|
return NEW;
|
||||||
end if;
|
end if;
|
||||||
|
@ -141,7 +141,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(org.hibernate.exception.ConstraintViolationException.class,
|
result.assertExceptionWithRootCauseMessage(org.hibernate.exception.ConstraintViolationException.class,
|
||||||
"ERROR: new row for relation \"hs_office.debitor\" violates check constraint \"check_default_prefix\"");
|
"ERROR: new row for relation \"debitor\" violates check constraint \"check_default_prefix\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user