Skip to content

Commit

Permalink
Merge pull request #220 from larsenle/main
Browse files Browse the repository at this point in the history
chore: Sprint 4 data seeding scripts
  • Loading branch information
ychung-mot authored Apr 24, 2024
2 parents f749da2 + 8b7f848 commit 052f672
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
31 changes: 31 additions & 0 deletions database/STR_DSS_Data_Seeding_NONPROD_Sprint_4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* STR DSS Sprint 4 NON-PROD Data Seeding */

MERGE INTO dss_organization AS tgt
USING ( SELECT * FROM (VALUES
('LG','LGTEST','Test Town'),
('LG','LGTEST2','Test City'),
('Platform','PLATFORMTEST2','Test Platform 2'),
('Platform','PLATFORMTEST','Test Platform 1'))
AS s (organization_type, organization_cd, organization_nm)
) AS src
ON (tgt.organization_cd=src.organization_cd)
WHEN matched and (
tgt.organization_nm!=src.organization_nm or
tgt.organization_type!=src.organization_type)
THEN UPDATE SET
organization_nm=src.organization_nm,
organization_type=src.organization_type
WHEN NOT MATCHED
THEN INSERT (organization_type, organization_cd, organization_nm)
VALUES (src.organization_type, src.organization_cd, src.organization_nm);

INSERT INTO dss_organization_contact_person
(is_primary, email_message_type, email_address_dsc, contacted_through_organization_id)
SELECT true, emt.email_message_type, :quoted_tester_email, o.organization_id
FROM dss_organization AS o, dss_email_message_type as emt
where o.organization_type='Platform'
and emt.email_message_type in ('Notice of Takedown','Takedown Request','Batch Takedown Request')
and NOT EXISTS (
SELECT 1
FROM dss_organization_contact_person AS ocp
WHERE o.organization_id=ocp.contacted_through_organization_id AND emt.email_message_type=ocp.email_message_type);
19 changes: 2 additions & 17 deletions database/STR_DSS_Data_Seeding_Sprint_4.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* STR DSS Sprint 4 NON-PROD Data Seeding */
/* STR DSS Sprint 4 Mandatory Data Seeding */

MERGE INTO dss_access_request_status AS tgt
USING ( SELECT * FROM (VALUES
Expand Down Expand Up @@ -130,11 +130,7 @@ VALUES (src.user_role_cd, src.user_privilege_cd);
MERGE INTO dss_organization AS tgt
USING ( SELECT * FROM (VALUES
('BCGov','CEU','Provincial Compliance and Enforcement Unit'),
('BCGov','BC','BC Government Staff'),
('LG','LGTEST','Test Town'),
('LG','LGTEST2','Test City'),
('Platform','PLATFORMTEST2','Test Platform 2'),
('Platform','PLATFORMTEST','Test Platform 1'))
('BCGov','BC','BC Government Staff'))
AS s (organization_type, organization_cd, organization_nm)
) AS src
ON (tgt.organization_cd=src.organization_cd)
Expand All @@ -147,14 +143,3 @@ organization_type=src.organization_type
WHEN NOT MATCHED
THEN INSERT (organization_type, organization_cd, organization_nm)
VALUES (src.organization_type, src.organization_cd, src.organization_nm);

INSERT INTO dss_organization_contact_person
(is_primary, email_message_type, email_address_dsc, contacted_through_organization_id)
SELECT true, emt.email_message_type, :quoted_tester_email, o.organization_id
FROM dss_organization AS o, dss_email_message_type as emt
where o.organization_type='Platform'
and emt.email_message_type in ('Notice of Takedown','Takedown Request','Batch Takedown Request')
and NOT EXISTS (
SELECT 1
FROM dss_organization_contact_person AS ocp
WHERE o.organization_id=ocp.contacted_through_organization_id AND emt.email_message_type=ocp.email_message_type);

0 comments on commit 052f672

Please sign in to comment.