From 83ce6423d1b25010d0a7f99c835aca81598ec0bf Mon Sep 17 00:00:00 2001 From: Dominic H Date: Fri, 27 Sep 2019 16:05:35 +0100 Subject: [PATCH] WIP for #432 - Also noted agreed standard for file naming extensions to migrations file --- migrations/012.community.down.sql | 13 +++++++++++++ migrations/012.community.up.sql | 28 ++++++++++++++++++++++++++++ migrations/README.md | 4 ++++ 3 files changed, 45 insertions(+) create mode 100644 migrations/012.community.down.sql create mode 100644 migrations/012.community.up.sql diff --git a/migrations/012.community.down.sql b/migrations/012.community.down.sql new file mode 100644 index 00000000..c3c92ed6 --- /dev/null +++ b/migrations/012.community.down.sql @@ -0,0 +1,13 @@ +-- Remove community fields + +-- Ownership type, enumerate type from: +ALTER TABLE buildings DROP COLUMN IF EXISTS ownership_type; + +-- Ownerhsip perception, would you describe this as a community asset? +-- Boolean yes / no +ALTER TABLE buildings DROP COLUMN IF EXISTS ownership_perception; + +-- Historic ownership type / perception +-- Has this building ever been used for community or public services activities? +-- Boolean yes / no +ALTER TABLE buildings DROP COLUMN IF EXISTS ownership_historic; diff --git a/migrations/012.community.up.sql b/migrations/012.community.up.sql new file mode 100644 index 00000000..d667affd --- /dev/null +++ b/migrations/012.community.up.sql @@ -0,0 +1,28 @@ +-- Remove community fields + +-- Ownership type, enumerate type from: +-- + +CREATE TYPE ownership_type +AS ENUM ('Private individual', + 'Private company', + 'Private offshore ownership', + 'Publicly owned', + 'Institutionally owned'); + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS ownership_type ownership_type DEFAULT 'Private individual'; + +-- Ownerhsip perception, would you describe this as a community asset? +-- Boolean yes / no +-- Below accepts t/f, yes/no, y/n, 0/1 as valid inputs all of which + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS ownership_perception boolean DEFAULT null; + +-- Historic ownership type / perception +-- Has this building ever been used for community or public services activities? +-- Boolean yes / no + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS ownership_historic boolean DEFAULT null; diff --git a/migrations/README.md b/migrations/README.md index d770f1c4..a772bd1c 100644 --- a/migrations/README.md +++ b/migrations/README.md @@ -53,3 +53,7 @@ Set or update passwords: ```bash psql -c "ALTER USER appusername WITH PASSWORD 'longsecurerandompassword';" ``` + +Syntax for adding to existing migration: + +`0##.filename-extension-#.up.sql`