From a03151af510efaad75da045cae796fd3c1f39d07 Mon Sep 17 00:00:00 2001 From: Dominic H Date: Fri, 13 Dec 2019 16:24:39 +0000 Subject: [PATCH] Migrations to enable the original landuse to be added to site - links to #500 - addresses #363 - addresses #491 --- migrations/016.landuse.down.sql | 15 --------------- migrations/0xx.type-extend.down.sql | 16 ++++++++++++++++ migrations/0xx.type-extend.up.sql | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 migrations/0xx.type-extend.down.sql create mode 100644 migrations/0xx.type-extend.up.sql diff --git a/migrations/016.landuse.down.sql b/migrations/016.landuse.down.sql index f7bc3f0b..5e1f869b 100644 --- a/migrations/016.landuse.down.sql +++ b/migrations/016.landuse.down.sql @@ -13,18 +13,3 @@ ALTER TABLE buildings DROP COLUMN IF EXISTS current_landuse_group; -- Land use order, singular. Client and db constrained. ALTER TABLE buildings DROP COLUMN IF EXISTS current_landuse_order; - - - ---=========================================== --- --- We also collect original landuse, structure & process is as current land use --- We don't currently collect intermediate historic uses --- ---=========================================== - --- Original Land use class or classes, array object, client constrained. -ALTER TABLE buildings DROP COLUMN IF EXISTS original_landuse_class; - --- Land use order, singular. Client and db constrained. -ALTER TABLE buildings DROP COLUMN IF EXISTS original_landuse_order; diff --git a/migrations/0xx.type-extend.down.sql b/migrations/0xx.type-extend.down.sql new file mode 100644 index 00000000..4860cfbf --- /dev/null +++ b/migrations/0xx.type-extend.down.sql @@ -0,0 +1,16 @@ +-- Building original use, collecting both class and order +ALTER TABLE buildings DROP COLUMN IF EXISTS original_landuse_class; + +-- [Disabled for launch] Date of change of use +-- This needs to pair with demolition +ALTER TABLE buildings DROP COLUMN IF EXISTS date_change_building_use; + + +-- Original Land use class or classes, array object, client constrained. +ALTER TABLE buildings DROP COLUMN IF EXISTS original_landuse_class; + +-- Land use order, singular. Client and db constrained. +ALTER TABLE buildings DROP COLUMN IF EXISTS original_landuse_order; + +-- Land use order, singular. Client and db constrained. +ALTER TABLE buildings DROP COLUMN IF EXISTS original_landuse_source; diff --git a/migrations/0xx.type-extend.up.sql b/migrations/0xx.type-extend.up.sql new file mode 100644 index 00000000..74ea4deb --- /dev/null +++ b/migrations/0xx.type-extend.up.sql @@ -0,0 +1,14 @@ +-- Land use order, singular. Client and db constrained with foreign key +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS original_landuse_order text, + ADD FOREIGN KEY (current_landuse_order) + REFERENCES reference_tables.buildings_landuse_order (description); + +-- Land use groups, array. Derived from classes. +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS original_landuse_group text ARRAY[41]; + + -- Land use class or classes, array object, client constrained. ARRAY[] is used to constrain array size. The array is limited to 250 based on Westfield Stratford as a single toid with many uses, this may want to be reduced down to reduce maximum size. + +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS original_landuse_class text ARRAY[250]; + +--Landuse source