2022-09-06 19:43:15 +02:00
|
|
|
|
--liquibase formatted sql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
|
|
|
|
--changeset hs-admin-contact-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a single contact test record.
|
|
|
|
|
*/
|
|
|
|
|
create or replace procedure createHsAdminContactTestData(contLabel varchar)
|
|
|
|
|
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
|
|
|
|
|
currentTask = 'creating RBAC test contact ' || contLabel;
|
|
|
|
|
call defineContext(currentTask, null, 'alex@hostsharing.net', 'global#global.admin');
|
|
|
|
|
execute format('set local hsadminng.currentTask to %L', currentTask);
|
|
|
|
|
|
2022-09-07 14:04:45 +02:00
|
|
|
|
emailAddr = 'customer-admin@' || cleanIdentifier(contLabel) || '.example.com';
|
2022-09-06 19:43:15 +02:00
|
|
|
|
|
|
|
|
|
raise notice 'creating test contact: %', contLabel;
|
|
|
|
|
insert
|
|
|
|
|
into hs_admin_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-07 14:04:45 +02:00
|
|
|
|
create or replace procedure createTestContactTestData(
|
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-07 14:04:45 +02:00
|
|
|
|
call createHsAdminContactTestData(intToVarChar(t, 4) || '#' || t);
|
2022-09-06 19:43:15 +02:00
|
|
|
|
commit;
|
|
|
|
|
end loop;
|
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
|
|
|
|
--changeset hs-admin-contact-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
do language plpgsql $$
|
|
|
|
|
begin
|
|
|
|
|
call createHsAdminContactTestData('first contact');
|
|
|
|
|
call createHsAdminContactTestData('second contact');
|
|
|
|
|
call createHsAdminContactTestData('third contact');
|
|
|
|
|
end;
|
|
|
|
|
$$;
|
|
|
|
|
--//
|