hs-customer SQL-Scripts in Liquibase

This commit is contained in:
Michael Hoennig 2022-07-29 12:14:22 +02:00
parent 8ba952a41d
commit 61c50c46ed
2 changed files with 18 additions and 3 deletions

View File

@ -104,6 +104,7 @@ create trigger createRbacRolesForCustomer_Trigger
execute procedure createRbacRolesForCustomer();
--//
-- ============================================================================
--changeset hs-customer-rbac-ROLES-REMOVAL:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
@ -116,8 +117,6 @@ create or replace function deleteRbacRulesForCustomer()
returns trigger
language plpgsql
strict as $$
declare
objectTable varchar = 'customer';
begin
if TG_OP = 'DELETE' then
call deleteRole(findRoleId(customerOwner(OLD)));

View File

@ -1,7 +1,23 @@
--liquibase formatted sql
-- ============================================================================
--changeset hs-customer-TEST-DATA-GENERATOR:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
/*
Generates a customer reference number for a given test data counter.
*/
create or replace function testCustomerReference(customerCount integer)
returns integer
returns null on null input
language plpgsql as $$
begin
return 10000 + customerCount;
end; $$;
/*
Creates test data for the customer main table.
*/
create or replace procedure createCustomerTestData(
startCount integer, -- count of auto generated rows before the run
endCount integer, -- count of auto generated rows after the run
@ -25,7 +41,7 @@ begin
set local hsadminng.currentTask to currentTask;
-- When a new customer is created,
custReference = 10000 + t;
custReference = testCustomerReference(t);
custRowId = uuid_generate_v4();
custPrefix = intToVarChar(t, 3);
custAdminName = 'admin@' || custPrefix || '.example.com';