Skip to content

Commit 226db52

Browse files
authored
Merge pull request #542 from larsenle/main
DSS-479 Database updates for BL data upload
2 parents 8b6d48d + 88aa140 commit 226db52

8 files changed

+3593
-5
lines changed

database/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ Each production release depends on the execution of a fixed set of scripts again
8282
- `ddl/STR_DSS_Views_Sprint_9.sql` **(not a typo)**
8383
- `ddl/STR_DSS_Views_Sprint_11.sql`
8484
- `seeding/STR_DSS_Data_Seeding_LGs_Sprint_11.sql`
85-
- `utility/DSS-627_Correct_UPLOAD_DELIVERY_Sprint_11.sql`
85+
- `utility/DSS-627_Correct_UPLOAD_DELIVERY_Sprint_11.sql`
86+
- Sprint 12:
87+
- `ddl/STR_DSS_Incremental_DB_DDL_Sprint_12.sql`
88+
- `ddl/STR_DSS_Views_Sprint_9.sql` **(not a typo)**
89+
- `seeding/STR_DSS_Data_Seeding_Sprint_12.sql`

database/ddl/STR_DSS_Physical_DB_DDL_Sprint_12.sql

Lines changed: 1052 additions & 0 deletions
Large diffs are not rendered by default.

database/model/PhysicalDataDiagram(Sprint12).svg

Lines changed: 1703 additions & 0 deletions
Loading
140 KB
Binary file not shown.

database/model/STR_DSS_Physical_DB_Design_Sprint_12.dbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,10 +1248,10 @@ END;$function$
12481248
<entity schema="dss" name="dss_upload_delivery" color="C0C139" x="768" y="656" />
12491249
<entity schema="dss" name="dss_upload_line" color="C0C139" x="1200" y="672" />
12501250
<entity schema="dss" name="dss_user_identity" color="C0C139" x="1296" y="352" />
1251-
<entity schema="dss" name="dss_user_privilege" color="C0C139" x="1584" y="816" />
1252-
<entity schema="dss" name="dss_user_role" color="C0C139" x="1600" y="672" />
1253-
<entity schema="dss" name="dss_user_role_assignment" color="C0C139" x="2096" y="608" />
1254-
<entity schema="dss" name="dss_user_role_privilege" color="C0C139" x="2080" y="768" />
1251+
<entity schema="dss" name="dss_user_privilege" color="C0C139" x="2048" y="608" />
1252+
<entity schema="dss" name="dss_user_role" color="C0C139" x="1616" y="832" />
1253+
<entity schema="dss" name="dss_user_role_assignment" color="C0C139" x="1488" y="1200" />
1254+
<entity schema="dss" name="dss_user_role_privilege" color="C0C139" x="2064" y="928" />
12551255
<callout x="64" y="48" pointer="Round" >
12561256
<comment><![CDATA[Ministry of Housing
12571257
Short Term Rental Data Sharing

database/model/STR_DSS_Physical_DB_Design_Sprint_12.md

Lines changed: 771 additions & 0 deletions
Large diffs are not rendered by default.
53.8 KB
Binary file not shown.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Sprint 12 Master Database Migration Script -- must be run from psql using the following command: \i '<folder>/<script>' (must use / rather than \) */
2+
\conninfo
3+
\encoding UTF8
4+
\set VERBOSITY terse
5+
\set ECHO none
6+
\set QUIET on
7+
\set AUTOCOMMIT off
8+
START TRANSACTION;
9+
SET search_path TO dss,public; /*schema name dss ignored if it does not exist*/
10+
SELECT current_schema() as dflt_schema
11+
\gset
12+
select exists(
13+
select 1 from information_schema.tables where table_name like 'dss%')
14+
as db_has_dss_tab
15+
\gset
16+
select exists(
17+
select 1 from information_schema.columns where column_name='governing_business_licence_id' and table_name='dss_rental_listing' and table_schema=:'dflt_schema')
18+
as list_has_bl_id
19+
\gset
20+
select exists(
21+
select 1 from information_schema.columns where column_name='local_government_type' and table_name='dss_organization' and table_schema=:'dflt_schema')
22+
as org_has_lg_type
23+
\gset
24+
\if :list_has_bl_id
25+
\echo 'Sprint 12 migration appears complete - Exiting without changes'
26+
\elif :org_has_lg_type
27+
\echo 'Sprint 11 migration appears complete - Beginning upgrade to Sprint 12'
28+
\echo 'Calling STR_DSS_Incremental_DB_DDL_Sprint_12.sql'
29+
\ir '../ddl/STR_DSS_Incremental_DB_DDL_Sprint_12.sql'
30+
\echo 'Replacing views'
31+
\ir '../ddl/STR_DSS_Views_Sprint_9.sql'
32+
\echo 'Calling STR_DSS_Data_Seeding_Sprint_12.sql'
33+
\ir '../seeding/STR_DSS_Data_Seeding_Sprint_12.sql'
34+
\elif :db_has_dss_tab
35+
\echo 'Database migration state is unknown - Exiting without changes'
36+
\else
37+
\echo 'Database has no DSS tables - Beginning complete build to Sprint 12'
38+
\echo 'Calling STR_DSS_Physical_DB_DDL_Sprint_12.sql'
39+
\ir '../ddl/STR_DSS_Physical_DB_DDL_Sprint_12.sql'
40+
\echo 'Calling STR_DSS_Data_Seeding_Sprint_12.sql'
41+
\ir '../seeding/STR_DSS_Data_Seeding_Sprint_12.sql'
42+
\echo 'Calling STR_DSS_Data_Seeding_Platforms_Sprint_10.sql'
43+
\ir '../seeding/STR_DSS_Data_Seeding_Platforms_Sprint_10.sql'
44+
\echo 'Platform contacts must be set manually'
45+
\echo 'Calling STR_DSS_Data_Seeding_LGs_Sprint_11.sql'
46+
\ir '../seeding/STR_DSS_Data_Seeding_LGs_Sprint_11.sql'
47+
\echo 'Calling STR_DSS_Data_Seeding_Geometry_Sprint_9.sql'
48+
\ir '../seeding/STR_DSS_Data_Seeding_Geometry_Sprint_9.sql'
49+
\endif
50+
\if :ERROR
51+
/*commit cannot succeed because transaction was aborted due to an error*/
52+
\echo 'Undoing transaction'
53+
ROLLBACK;
54+
\else
55+
\echo 'Committing transaction'
56+
COMMIT;
57+
\endif
58+
\echo done!

0 commit comments

Comments
 (0)