Skip to content

Commit

Permalink
Merge pull request #735 from larsenle/main
Browse files Browse the repository at this point in the history
Sprint 16 scripting adjustments (fix dss_organization.is_active)
  • Loading branch information
ychung-mot authored Oct 23, 2024
2 parents d037253 + b6e3bbd commit ae89eb3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions database/seeding/STR_DSS_Data_Seeding_Geometry_Sprint_16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ AS s (parent_organization_cd,organization_cd,organization_nm,is_principal_reside
) AS src
ON (tgt.organization_cd=src.organization_cd)
WHEN matched and (
coalesce(tgt.is_active, false) != true or
tgt.organization_nm!=src.organization_nm or
tgt.organization_type!='LGSub' or
tgt.is_principal_residence_required!=src.is_principal_residence_required or
Expand All @@ -810,15 +811,16 @@ tgt.area_geometry IS NULL or
(tgt.managing_organization_id IS NOT NULL AND src.parent_organization_cd IS NULL) OR
(SELECT UPPER(o.organization_cd) FROM dss_organization AS o WHERE o.organization_id=tgt.managing_organization_id)!=UPPER(src.parent_organization_cd))
THEN UPDATE SET
is_active = true,
organization_nm=src.organization_nm,
organization_type='LGSub',
is_principal_residence_required=src.is_principal_residence_required,
is_business_licence_required=src.is_business_licence_required,
area_geometry=src.area_geometry,
managing_organization_id=(select o.organization_id from dss_organization as o where UPPER(o.organization_cd)=UPPER(src.parent_organization_cd))
WHEN NOT MATCHED
THEN INSERT (organization_type,organization_cd,organization_nm,is_principal_residence_required,is_business_licence_required,area_geometry,managing_organization_id)
VALUES ( 'LGSub',src.organization_cd,src.organization_nm,src.is_principal_residence_required,src.is_business_licence_required,src.area_geometry,(select o.organization_id from dss_organization as o where UPPER(o.organization_cd)=UPPER(src.parent_organization_cd)));
THEN INSERT (is_active,organization_type,organization_cd,organization_nm,is_principal_residence_required,is_business_licence_required,area_geometry,managing_organization_id)
VALUES (true,'LGSub',src.organization_cd,src.organization_nm,src.is_principal_residence_required,src.is_business_licence_required,src.area_geometry,(select o.organization_id from dss_organization as o where UPPER(o.organization_cd)=UPPER(src.parent_organization_cd)));

MERGE INTO dss_organization AS tgt
USING ( SELECT * FROM (VALUES
Expand Down
6 changes: 4 additions & 2 deletions database/seeding/STR_DSS_Data_Seeding_LGs_Sprint_16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,16 @@ AS s (local_government_type, organization_cd, organization_nm)
) AS src
ON (tgt.organization_cd=UPPER(src.organization_cd))
WHEN matched and (
coalesce(tgt.is_active, false) != true or
tgt.organization_nm!=src.organization_nm or
tgt.organization_type!='LG' or
tgt.local_government_type!=src.local_government_type or
tgt.local_government_type is null)
THEN UPDATE SET
is_active = true,
organization_nm=src.organization_nm,
organization_type='LG',
local_government_type=src.local_government_type
WHEN NOT MATCHED
THEN INSERT (organization_type, organization_cd, organization_nm, local_government_type)
VALUES ('LG', src.organization_cd, src.organization_nm, src.local_government_type);
THEN INSERT (is_active, organization_type, organization_cd, organization_nm, local_government_type)
VALUES (true, 'LG', src.organization_cd, src.organization_nm, src.local_government_type);
6 changes: 4 additions & 2 deletions database/seeding/STR_DSS_Data_Seeding_Sprint_16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ AS s (organization_type, organization_cd, organization_nm)
) AS src
ON (tgt.organization_cd=src.organization_cd)
WHEN matched and (
coalesce(tgt.is_active, false) != true or
tgt.organization_nm!=src.organization_nm or
tgt.organization_type!=src.organization_type)
THEN UPDATE SET
is_active = true,
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);
THEN INSERT (is_active, organization_type, organization_cd, organization_nm)
VALUES (true, src.organization_type, src.organization_cd, src.organization_nm);
2 changes: 2 additions & 0 deletions database/utility/STR_DSS_Migration_Sprint_16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ as db_has_s15_col
\ir '../seeding/STR_DSS_Data_Seeding_Sprint_16.sql'
\echo 'Calling STR_DSS_Data_Seeding_LGs_Sprint_16.sql'
\ir '../seeding/STR_DSS_Data_Seeding_LGs_Sprint_16.sql'
\echo 'Calling STR_DSS_Data_Seeding_Geometry_Sprint_16.sql'
\ir '../seeding/STR_DSS_Data_Seeding_Geometry_Sprint_16.sql'
\elif :db_has_dss_tab
\echo 'Database migration state is unknown - Exiting without changes'
\else
Expand Down

0 comments on commit ae89eb3

Please sign in to comment.