From 35f6eebeb631a5ef944d331e2194bbd02fc7f5bf Mon Sep 17 00:00:00 2001 From: Dominic H Date: Thu, 15 Aug 2019 14:28:27 +0100 Subject: [PATCH 1/3] Sustainability sub categories for launch #360 - Tested on local db --- migrations/011.sustainability.down.sql | 26 ++++++++++++ migrations/012.sustainability.up.sql | 58 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 migrations/011.sustainability.down.sql create mode 100644 migrations/012.sustainability.up.sql diff --git a/migrations/011.sustainability.down.sql b/migrations/011.sustainability.down.sql new file mode 100644 index 00000000..252ed0b3 --- /dev/null +++ b/migrations/011.sustainability.down.sql @@ -0,0 +1,26 @@ +-- Remove sustainability fields, update in paralell with adding new fields +-- BREEAM rating +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_rating; +-- BREEAM date +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_date; + +-- DEC (display energy certifcate, only applies to non domestic buildings) +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec; +-- DEC date +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_date; + +--TODO: DEC certifcate number, is there an online store for these? + +-- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_aggregate_estimate_epc; + +-- Last significant retrofit date YYYY +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_retrofit_date; + +--TODO : Embodied carbon + +--TODO : Life expectancy minimum + +--TODO : Average lifespan for typology + +--TODO : Adaptability rating diff --git a/migrations/012.sustainability.up.sql b/migrations/012.sustainability.up.sql new file mode 100644 index 00000000..1be3da7f --- /dev/null +++ b/migrations/012.sustainability.up.sql @@ -0,0 +1,58 @@ +-- BREEAM ratings, one of: +-- - Outstanding +-- - Excellent +-- - Very good +-- - Good +-- - Pass +-- - Unclassified +CREATE TYPE sust_breeam_rating +AS ENUM ('Outstanding', + 'Excellent', + 'Very good', + 'Good', + 'Pass', + 'Unclassified'); + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_breeam_rating sust_breeam_rating DEFAULT 'Unclassified'; + +-- Date of BREEAM +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_breeam_date smallint; + +-- DEC (display energy certifcate, only applies to non domestic buildings) +-- A - G +CREATE TYPE sust_dec +AS ENUM ('A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G'); + +-- Date of DEC YYYY +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_dec_date smallint; + + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_dec sust_dec; + +-- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates +-- A+ - G +CREATE TYPE sust_aggregate_estimate_epc +AS ENUM ('A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G'); + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_aggregate_estimate_epc sust_aggregate_estimate_epc; + +-- Last significant retrofit date YYYY +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_retrofit_date smallint; From 21c2c6cccc3aad1353002626a3a527f0db3c07bc Mon Sep 17 00:00:00 2001 From: Dominic H Date: Thu, 29 Aug 2019 16:13:09 +0100 Subject: [PATCH 2/3] Addresses review comments for #360 --- migrations/011.sustainability.down.sql | 14 ++++++++------ migrations/012.sustainability.up.sql | 9 +++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/migrations/011.sustainability.down.sql b/migrations/011.sustainability.down.sql index 252ed0b3..8cdf14eb 100644 --- a/migrations/011.sustainability.down.sql +++ b/migrations/011.sustainability.down.sql @@ -9,7 +9,8 @@ ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec; -- DEC date ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_date; ---TODO: DEC certifcate number, is there an online store for these? +--DEC certifcate lmk key, this would be lmkkey, no online lookup but can scrape through API. Numeric (25) +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_lmkey; -- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates ALTER TABLE buildings DROP COLUMN IF EXISTS sust_aggregate_estimate_epc; @@ -17,10 +18,11 @@ ALTER TABLE buildings DROP COLUMN IF EXISTS sust_aggregate_estimate_epc; -- Last significant retrofit date YYYY ALTER TABLE buildings DROP COLUMN IF EXISTS sust_retrofit_date; ---TODO : Embodied carbon +--How much embodied carbon? One for ML, tons CO2 int +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_embodied_carbon; ---TODO : Life expectancy minimum +--Life expectancy of the building, via further analysis +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_life_expectancy; ---TODO : Average lifespan for typology - ---TODO : Adaptability rating +--Average lifespan of typology based on statistical analysis of similar stock +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_lifespan_average; diff --git a/migrations/012.sustainability.up.sql b/migrations/012.sustainability.up.sql index 1be3da7f..c76d0133 100644 --- a/migrations/012.sustainability.up.sql +++ b/migrations/012.sustainability.up.sql @@ -56,3 +56,12 @@ ALTER TABLE buildings -- Last significant retrofit date YYYY ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_retrofit_date smallint; + +--How much embodied carbon? One for ML, tons CO2 int +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_embodied_carbon numeric(7,2); + +--Life expectancy of the building, via further analysis +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_life_expectancy smallint; + +--Average lifespan of typology based on statistical analysis of similar stock +ALTER TABLE buildings ADD COLUMN IF NOTE EXISTS sust_lifespan_average smallint; From f9a48f4a55910f67c748a058438034f7b369d437 Mon Sep 17 00:00:00 2001 From: dominic Date: Fri, 30 Aug 2019 13:02:37 +0100 Subject: [PATCH 3/3] File rename to follow conventions for #360 - In future years do we want tocapture DEC certifcate date? --- .../{012.sustainability.up.sql => 011.sustainability.up.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename migrations/{012.sustainability.up.sql => 011.sustainability.up.sql} (100%) diff --git a/migrations/012.sustainability.up.sql b/migrations/011.sustainability.up.sql similarity index 100% rename from migrations/012.sustainability.up.sql rename to migrations/011.sustainability.up.sql