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.
|
|
|
|
|
*/
|
2024-05-06 09:22:21 +02:00
|
|
|
|
create or replace procedure createHsOfficeContactTestData(contCaption varchar)
|
2022-09-06 19:43:15 +02:00
|
|
|
|
language plpgsql as $$
|
|
|
|
|
declare
|
2024-04-30 12:27:20 +02:00
|
|
|
|
postalAddr varchar;
|
|
|
|
|
emailAddr varchar;
|
2022-09-06 19:43:15 +02:00
|
|
|
|
begin
|
2024-05-06 09:22:21 +02:00
|
|
|
|
emailAddr = 'contact-admin@' || cleanIdentifier(contCaption) || '.example.com';
|
2024-09-13 08:16:22 +02:00
|
|
|
|
call basis.defineContext('creating contact test-data');
|
2022-09-09 17:43:43 +02:00
|
|
|
|
perform createRbacUser(emailAddr);
|
2024-09-13 08:16:22 +02:00
|
|
|
|
call basis.defineContext('creating contact test-data', null, emailAddr);
|
2022-09-06 19:43:15 +02:00
|
|
|
|
|
2024-04-30 12:27:20 +02:00
|
|
|
|
postalAddr := E'Vorname Nachname\nStraße Hnr\nPLZ Stadt';
|
|
|
|
|
|
2024-05-06 09:22:21 +02:00
|
|
|
|
raise notice 'creating test contact: %', contCaption;
|
2022-09-06 19:43:15 +02:00
|
|
|
|
insert
|
2024-05-06 09:22:21 +02:00
|
|
|
|
into hs_office_contact (caption, postaladdress, emailaddresses, phonenumbers)
|
2024-04-30 12:27:20 +02:00
|
|
|
|
values (
|
2024-05-06 09:22:21 +02:00
|
|
|
|
contCaption,
|
2024-04-30 12:27:20 +02:00
|
|
|
|
postalAddr,
|
|
|
|
|
('{ "main": "' || emailAddr || '" }')::jsonb,
|
|
|
|
|
('{ "phone_office": "+49 123 1234567" }')::jsonb
|
|
|
|
|
);
|
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
|
2024-09-13 08:08:19 +02:00
|
|
|
|
call createHsOfficeContactTestData(basis.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');
|
2024-02-01 14:48:15 +01:00
|
|
|
|
call createHsOfficeContactTestData('fourth 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;
|
|
|
|
|
$$;
|
|
|
|
|
--//
|