diff --git a/database/seeding/STR_DSS_Data_Seeding_Geometry_Sprint_16.sql b/database/seeding/STR_DSS_Data_Seeding_Geometry_Sprint_16.sql index bc200f1f..9eb8e3db 100644 --- a/database/seeding/STR_DSS_Data_Seeding_Geometry_Sprint_16.sql +++ b/database/seeding/STR_DSS_Data_Seeding_Geometry_Sprint_16.sql @@ -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 @@ -810,6 +811,7 @@ 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, @@ -817,8 +819,8 @@ 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 diff --git a/database/seeding/STR_DSS_Data_Seeding_LGs_Sprint_16.sql b/database/seeding/STR_DSS_Data_Seeding_LGs_Sprint_16.sql index b5a11647..5dbe2bba 100644 --- a/database/seeding/STR_DSS_Data_Seeding_LGs_Sprint_16.sql +++ b/database/seeding/STR_DSS_Data_Seeding_LGs_Sprint_16.sql @@ -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); diff --git a/database/seeding/STR_DSS_Data_Seeding_Sprint_16.sql b/database/seeding/STR_DSS_Data_Seeding_Sprint_16.sql index 683b2f42..8889a794 100644 --- a/database/seeding/STR_DSS_Data_Seeding_Sprint_16.sql +++ b/database/seeding/STR_DSS_Data_Seeding_Sprint_16.sql @@ -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); diff --git a/database/utility/STR_DSS_Migration_Sprint_16.sql b/database/utility/STR_DSS_Migration_Sprint_16.sql index 1b495bf3..b0eacf9f 100644 --- a/database/utility/STR_DSS_Migration_Sprint_16.sql +++ b/database/utility/STR_DSS_Migration_Sprint_16.sql @@ -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