2022-09-06 19:43:15 +02:00
|
|
|
|
--liquibase formatted sql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
2022-09-13 13:27:52 +02:00
|
|
|
|
--changeset hs-office-contact-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
2022-09-06 19:43:15 +02:00
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a single contact test record.
|
|
|
|
|
*/
|
2022-09-13 13:27:52 +02:00
|
|
|
|
create or replace procedure createHsOfficeContactTestData(contLabel varchar)
|
2022-09-06 19:43:15 +02:00
|
|
|
|
language plpgsql as $$
|
|
|
|
|
declare
|
|
|
|
|
currentTask varchar;
|
2022-09-07 14:04:45 +02:00
|
|
|
|
emailAddr varchar;
|
2022-09-06 19:43:15 +02:00
|
|
|
|
begin
|
2022-10-13 10:36:20 +02:00
|
|
|
|
currentTask = 'creating contact test-data ' || contLabel;
|
2022-09-06 19:43:15 +02:00
|
|
|
|
execute format('set local hsadminng.currentTask to %L', currentTask);
|
|
|
|
|
|
2022-09-26 10:57:22 +02:00
|
|
|
|
emailAddr = 'contact-admin@' || cleanIdentifier(contLabel) || '.example.com';
|
2022-09-09 17:43:43 +02:00
|
|
|
|
call defineContext(currentTask);
|
|
|
|
|
perform createRbacUser(emailAddr);
|
|
|
|
|
call defineContext(currentTask, null, emailAddr);
|
2022-09-06 19:43:15 +02:00
|
|
|
|
|
|
|
|
|
raise notice 'creating test contact: %', contLabel;
|
|
|
|
|
insert
|
2022-09-13 13:27:52 +02:00
|
|
|
|
into hs_office_contact (label, postaladdress, emailaddresses, phonenumbers)
|
2022-09-07 14:04:45 +02:00
|
|
|
|
values (contLabel, $address$
|
2022-09-06 19:43:15 +02:00
|
|
|
|
Vorname Nachname
|
|
|
|
|
Straße Hnr
|
|
|
|
|
PLZ Stadt
|
2022-09-07 14:04:45 +02:00
|
|
|
|
$address$, emailAddr, '+49 123 1234567');
|
2022-09-06 19:43:15 +02:00
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
/*
|
2022-09-07 14:04:45 +02:00
|
|
|
|
Creates a range of test contact for mass data generation.
|
2022-09-06 19:43:15 +02:00
|
|
|
|
*/
|
2022-09-13 13:27:52 +02:00
|
|
|
|
create or replace procedure createHsOfficeContactTestData(
|
2022-09-06 19:43:15 +02:00
|
|
|
|
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
|
2022-09-13 13:27:52 +02:00
|
|
|
|
call createHsOfficeContactTestData(intToVarChar(t, 4) || '#' || t);
|
2022-09-06 19:43:15 +02:00
|
|
|
|
commit;
|
|
|
|
|
end loop;
|
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
2022-09-13 13:27:52 +02:00
|
|
|
|
--changeset hs-office-contact-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
2022-09-06 19:43:15 +02:00
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
do language plpgsql $$
|
|
|
|
|
begin
|
2022-09-15 13:32:01 +02:00
|
|
|
|
-- TODO: use better names
|
2022-09-13 13:27:52 +02:00
|
|
|
|
call createHsOfficeContactTestData('first contact');
|
|
|
|
|
call createHsOfficeContactTestData('second contact');
|
|
|
|
|
call createHsOfficeContactTestData('third contact');
|
|
|
|
|
call createHsOfficeContactTestData('forth contact');
|
2022-09-15 13:32:01 +02:00
|
|
|
|
call createHsOfficeContactTestData('fifth contact');
|
|
|
|
|
call createHsOfficeContactTestData('sixth contact');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
call createHsOfficeContactTestData('seventh contact');
|
2022-09-15 13:32:01 +02:00
|
|
|
|
call createHsOfficeContactTestData('eighth contact');
|
|
|
|
|
call createHsOfficeContactTestData('ninth contact');
|
|
|
|
|
call createHsOfficeContactTestData('tenth contact');
|
|
|
|
|
call createHsOfficeContactTestData('eleventh contact');
|
|
|
|
|
call createHsOfficeContactTestData('twelfth contact');
|
2022-09-06 19:43:15 +02:00
|
|
|
|
end;
|
|
|
|
|
$$;
|
|
|
|
|
--//
|