Switching to josnb object for #362

This commit is contained in:
dominic 2019-08-30 16:06:36 +01:00 committed by Tom Russell
parent 96aee71a4d
commit 076742adf8
2 changed files with 5 additions and 48 deletions

View File

@ -1,10 +1,3 @@
-- Remove team fields, update in paralell with adding new fields
--Numeric small int, if > 1 triggers multifield boxes on fron end
ALTER TABLE buildings DROP COLUMN IF EXISTS number_of_awards;
-- Award or awards (may be multiple) stored as json b object
ALTER TABLE buildings DROP COLUMN IF EXISTS team_awards;
--This is a pair to team_awards each may have one
ALTER TABLE buildings DROP COLUMN IF EXISTS award_year;

View File

@ -1,44 +1,8 @@
-- Remove team fields, update in paralell with adding new fields
--Numeric small int, if > 1 triggers multifield boxes on fron end
--Storing as json b, create column defined as jsonb
--This contains the award name and award year
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS number_of_awards smallint;
-- Building award, can be any of:
-- This is an edit of all potential awards to the most commonly recognised with bias to community, hertiage and design focussed ones
CREATE TYPE team_awards
AS ENUM ('Architects Journal - Heritage Project',
'Architects Journal - Housing Project',
'Architects Journal - Community & Faith Project',
'Architects Journal - Small projects award',
'Architects Journal - Public Building of the Year',
'Architects Journal - Refurb of the Year',
'BREEAM Award',
'CIBSE Building Performance Awards',
'Civic Voice Design Award',
'Historic England best rescue of a building or place',
'Historic England followers'' favourite',
'ICE London Civil Engineering Awards',
'Neave Brown Award',
'New London Architecture awards - Conservation and retrofit',
'New London Architecture awards - Mayors Prize',
'New London Architecture awards - Culture & Community',
'New London Architecture awards - Education',
'New London Architecture awards - Homes',
'New London Architecture awards - Housing',
'New London Architecture awards - Offices',
'RIBA Gold medal',
'RIBA Stirling prize',
'RIBA Regional award',
'Stephen Lawrence Prize',
'The Civic Trust Award',
'The Pritzker Architecture Prize',
'The Royal Academy of Engineering Major Projects Award',
'The Manser Medal - AJ House of the Year',
'None');
ADD COLUMN IF NOT EXISTS team_awards jsonb;
--To validate this input, the following confirms it's an valid object but not that the items in the object are validated agains those we will acccept
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS team_awards team_awards DEFAULT 'None';
--This is a pair to team_awards each may have one
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS award_year smallint;
ADD CONSTRAINT data_is_valid CHECK (is_jsonb_valid ('{"type": "object"}', team_awards));