2022-09-07 20:24:35 +02:00
|
|
|
|
--liquibase formatted sql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
2024-09-16 15:36:37 +02:00
|
|
|
|
--changeset michael.hoennig:hs-office-person-TEST-DATA-GENERATOR endDelimiter:--//
|
2022-09-07 20:24:35 +02:00
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a single person test record.
|
|
|
|
|
*/
|
2022-09-13 13:27:52 +02:00
|
|
|
|
create or replace procedure createHsOfficePersonTestData(
|
|
|
|
|
newPersonType HsOfficePersonType,
|
2022-09-09 17:43:43 +02:00
|
|
|
|
newTradeName varchar,
|
|
|
|
|
newFamilyName varchar = null,
|
|
|
|
|
newGivenName varchar = null
|
2022-09-07 20:24:35 +02:00
|
|
|
|
)
|
|
|
|
|
language plpgsql as $$
|
|
|
|
|
declare
|
|
|
|
|
fullName varchar;
|
|
|
|
|
emailAddr varchar;
|
|
|
|
|
begin
|
2022-09-09 17:43:43 +02:00
|
|
|
|
fullName := concat_ws(', ', newTradeName, newFamilyName, newGivenName);
|
2024-09-16 15:36:37 +02:00
|
|
|
|
emailAddr = 'person-' || left(base.cleanIdentifier(fullName), 32) || '@example.com';
|
|
|
|
|
call base.defineContext('creating person test-data');
|
|
|
|
|
perform rbac.create_subject(emailAddr);
|
|
|
|
|
call base.defineContext('creating person test-data', null, emailAddr);
|
2022-09-07 20:24:35 +02:00
|
|
|
|
|
2024-03-28 12:15:13 +01:00
|
|
|
|
raise notice 'creating test person: % by %', fullName, emailAddr;
|
2022-09-07 20:24:35 +02:00
|
|
|
|
insert
|
2024-09-18 10:28:21 +02:00
|
|
|
|
into hs_office.person (persontype, tradename, givenname, familyname)
|
2022-09-09 17:43:43 +02:00
|
|
|
|
values (newPersonType, newTradeName, newGivenName, newFamilyName);
|
2022-09-07 20:24:35 +02:00
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a range of test persons for mass data generation.
|
|
|
|
|
*/
|
|
|
|
|
create or replace procedure createTestPersonTestData(
|
|
|
|
|
startCount integer, -- count of auto generated rows before the run
|
|
|
|
|
endCount integer -- count of auto generated rows after the run
|
|
|
|
|
)
|
|
|
|
|
language plpgsql as $$
|
|
|
|
|
begin
|
|
|
|
|
for t in startCount..endCount
|
|
|
|
|
loop
|
2024-09-16 15:36:37 +02:00
|
|
|
|
call createHsOfficePersonTestData('LP', base.intToVarChar(t, 4));
|
2022-09-07 20:24:35 +02:00
|
|
|
|
commit;
|
|
|
|
|
end loop;
|
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
2024-09-16 15:36:37 +02:00
|
|
|
|
--changeset michael.hoennig:hs-office-person-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--//
|
2022-09-07 20:24:35 +02:00
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
do language plpgsql $$
|
|
|
|
|
begin
|
2024-02-01 14:48:15 +01:00
|
|
|
|
call createHsOfficePersonTestData('LP', 'Hostsharing eG');
|
2024-01-24 15:18:44 +01:00
|
|
|
|
call createHsOfficePersonTestData('LP', 'First GmbH');
|
2024-02-01 14:48:15 +01:00
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Firby', 'Susan');
|
2024-01-24 15:18:44 +01:00
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Smith', 'Peter');
|
2024-02-01 14:48:15 +01:00
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Tucker', 'Jack');
|
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Fouler', 'Ellie');
|
|
|
|
|
call createHsOfficePersonTestData('LP', 'Second e.K.', 'Smith', 'Peter');
|
2024-01-24 15:18:44 +01:00
|
|
|
|
call createHsOfficePersonTestData('IF', 'Third OHG');
|
2024-03-28 12:15:13 +01:00
|
|
|
|
call createHsOfficePersonTestData('LP', 'Fourth eG');
|
2024-01-24 15:18:44 +01:00
|
|
|
|
call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler');
|
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Bessler', 'Anita');
|
2024-03-28 12:15:13 +01:00
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Bessler', 'Bert');
|
2024-01-24 15:18:44 +01:00
|
|
|
|
call createHsOfficePersonTestData('NP', null, 'Winkler', 'Paul');
|
2022-09-07 20:24:35 +02:00
|
|
|
|
end;
|
|
|
|
|
$$;
|
|
|
|
|
--//
|