From aeff1a69fc48faa38edc62bbf2ebe9c04243e0c8 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 10 Nov 2021 11:58:36 +0000 Subject: [PATCH] update miration and some mappings --- app/constants/db_enums.rb | 2 +- app/models/case_log.rb | 1 + config/forms/2021_2022.json | 35 ++++----- .../20211108134601_further_core_migrations.rb | 77 ++++++++++++------- ...211108143649_further_change_field_types.rb | 21 ----- db/schema.rb | 20 ++--- 6 files changed, 80 insertions(+), 76 deletions(-) delete mode 100644 db/migrate/20211108143649_further_change_field_types.rb diff --git a/app/constants/db_enums.rb b/app/constants/db_enums.rb index 3ea39dcca..bb904f0ef 100644 --- a/app/constants/db_enums.rb +++ b/app/constants/db_enums.rb @@ -20,7 +20,7 @@ module DbEnums "Not seeking work" => 6, "Full-time student" => 7, "Unable to work because of long term sick or disability" => 8, - "Child under 16" => 100, + "Child under 16" => 9, "Other" => 0, "Prefer not to say" => 10, } diff --git a/app/models/case_log.rb b/app/models/case_log.rb index c835c129d..55060ad2c 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -107,6 +107,7 @@ class CaseLog < ApplicationRecord enum majorrepairs: DbEnums.polar, _suffix: true enum hb: DbEnums.housing_benefit, _suffix: true enum hbrentshortfall: DbEnums.polar_with_unknown, _suffix: true + enum property_relet: DbEnums.polar, _suffix: true AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 37c61a63c..d27ba215b 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -273,24 +273,23 @@ "type": "radio", "answer_options": { "0": "UK national resident in UK", - "1": "A current or former reserve in the UK Armed Forces (exc. National Service)", - "2": "UK national returning from residence overseas", - "3": "Czech Republic", - "4": "Estonia", - "5": "Hungary", - "6": "Latvia", - "7": "Lithuania", - "8": "Poland", - "9": "Slovakia", - "10": "Bulgaria", - "11": "Romania", - "12": "Ireland", - "13": "Slovakia", - "14":"Slovenia", - "15": "Croatia", - "16": "Other EU Economic Area (EEA country)", - "17": "Any other country", - "18": "Prefer not to say" + "1": "UK national returning from residence overseas", + "2": "Czech Republic", + "3": "Estonia", + "4": "Hungary", + "5": "Latvia", + "6": "Lithuania", + "7": "Poland", + "8": "Slovakia", + "9": "Bulgaria", + "10": "Romania", + "11": "Ireland", + "12": "Slovakia", + "13":"Slovenia", + "14": "Croatia", + "15": "Other EU Economic Area (EEA country)", + "16": "Any other country", + "17": "Prefer not to say" } } } diff --git a/db/migrate/20211108134601_further_core_migrations.rb b/db/migrate/20211108134601_further_core_migrations.rb index 3ab7d800e..4746c6d3e 100644 --- a/db/migrate/20211108134601_further_core_migrations.rb +++ b/db/migrate/20211108134601_further_core_migrations.rb @@ -1,33 +1,58 @@ class FurtherCoreMigrations < ActiveRecord::Migration[6.1] def up - remove_column :case_logs, :condition_effects_prefer_not_to_say - rename_column :case_logs, :reason_for_leaving_last_settled_home, :reason - rename_column :case_logs, :property_reference, :propcode - rename_column :case_logs, :property_major_repairs, :majorrepairs - rename_column :case_logs, :property_location, :la - rename_column :case_logs, :previous_la, :prevloc - rename_column :case_logs, :housing_benefit, :hb - rename_column :case_logs, :outstanding_rent_or_charges, :hbrentshortfall - rename_column :case_logs, :outstanding_amount, :tshortfall - add_column :case_logs, :postcode, :string - add_column :case_logs, :postcod2, :string - add_column :case_logs, :ppostc1, :string - add_column :case_logs, :ppostc2, :string + change_table :case_logs, bulk: true do |t| + t.remove :condition_effects_prefer_not_to_say + t.remove :reason_for_leaving_last_settled_home + t.column :reason, :integer + t.remove :property_reference + t.column :propcode, :string + t.remove :property_major_repairs + t.column :majorrepairs, :integer + t.remove :property_location + t.column :la, :string + t.remove :previous_la + t.column :prevloc, :string + t.remove :housing_benefit + t.column :hb, :integer + t.remove :outstanding_rent_or_charges + t.column :hbrentshortfall, :integer + t.remove :outstanding_amount + t.column :tshortfall, :integer + t.column :postcode, :string + t.column :postcod2, :string + t.column :ppostc1, :string + t.column :ppostc2, :string + t.remove :property_relet + t.column :property_relet, :integer + end end def down - add_column :case_logs, :condition_effects_prefer_not_to_say, :integer - rename_column :case_logs, :reason, :reason_for_leaving_last_settled_home - rename_column :case_logs, :propcode, :property_reference - rename_column :case_logs, :majorrepairs, :property_major_repairs - rename_column :case_logs, :la, :property_location - rename_column :case_logs, :prevloc, :previous_la - rename_column :case_logs, :hb, :housing_benefit - rename_column :case_logs, :hbrentshortfall, :outstanding_rent_or_charges - rename_column :case_logs, :tshortfall, :outstanding_amount - remove_column :case_logs, :postcode - remove_column :case_logs, :postcod2 - remove_column :case_logs, :ppostc1 - remove_column :case_logs, :ppostc2 + change_table :case_logs, bulk: true do |t| + t.column :condition_effects_prefer_not_to_say, :integer + t.column :condition_effects_prefer_not_to_say, :integer + t.column :reason_for_leaving_last_settled_home, :string + t.remove :reason + t.column :property_reference, :string + t.remove :propcode + t.column :property_major_repairs, :string + t.remove :majorrepairs + t.column :property_location, :string + t.remove :la + t.column :previous_la, :string + t.remove :prevloc + t.column :housing_benefit, :string + t.remove :hb + t.column :outstanding_rent_or_charges, :string + t.remove :hbrentshortfall + t.column :outstanding_amount, :string + t.remove :tshortfall + t.remove :postcode + t.remove :postcod2 + t.remove :ppostc1 + t.remove :ppostc2 + t.remove :property_relet + t.column :property_relet, :string + end end end diff --git a/db/migrate/20211108143649_further_change_field_types.rb b/db/migrate/20211108143649_further_change_field_types.rb deleted file mode 100644 index c596f162a..000000000 --- a/db/migrate/20211108143649_further_change_field_types.rb +++ /dev/null @@ -1,21 +0,0 @@ -class FurtherChangeFieldTypes < ActiveRecord::Migration[6.1] - def up - change_table :case_logs, bulk: true do |t| - t.change :reason, "integer USING reason::integer" - t.change :majorrepairs, "integer USING majorrepairs::integer" - t.change :hb, "integer USING hb::integer" - t.change :hbrentshortfall, "integer USING hbrentshortfall::integer" - t.change :tshortfall, "integer USING tshortfall::integer" - end - end - - def down - change_table :case_logs, bulk: true do |t| - t.change :reason, :string - t.change :majorrepairs, :string - t.change :hb, :string - t.change :hbrentshortfall, :string - t.change :tshortfall, :string - end - end -end diff --git a/db/schema.rb b/db/schema.rb index e47645fc9..a1b19f7f2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_11_08_143649) do +ActiveRecord::Schema.define(version: 2021_11_08_134601) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -57,7 +57,6 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do t.string "sex8" t.integer "ecstat8" t.integer "homeless" - t.integer "reason" t.integer "underoccupation_benefitcap" t.integer "leftreg" t.integer "reservist" @@ -73,40 +72,32 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do t.integer "tenancy" t.string "lettype" t.integer "landlord" - t.string "la" t.string "previous_postcode" - t.string "property_relet" t.integer "rsnvac" - t.string "propcode" t.integer "unittype_gn" t.string "property_building_type" t.integer "beds" t.string "property_void_date" - t.integer "majorrepairs" t.string "property_major_repairs_date" t.integer "offered" t.integer "wchair" t.integer "earnings" t.integer "incfreq" t.integer "benefits" - t.integer "hb" t.integer "period" t.integer "brent" t.integer "scharge" t.integer "pscharge" t.integer "supcharg" t.integer "tcharge" - t.integer "tshortfall" t.integer "layear" t.integer "lawaitlist" - t.string "prevloc" t.string "property_postcode" t.integer "reasonpref" t.string "reasonable_preference_reason" t.integer "cbl" t.integer "chr" t.integer "cap" - t.integer "hbrentshortfall" t.string "other_reason_for_leaving_last_settled_home" t.integer "housingneeds_a" t.integer "housingneeds_b" @@ -145,10 +136,19 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do t.string "needs_type" t.string "sale_completion_date" t.string "purchaser_code" + t.integer "reason" + t.string "propcode" + t.integer "majorrepairs" + t.string "la" + t.string "prevloc" + t.integer "hb" + t.integer "hbrentshortfall" + t.integer "tshortfall" t.string "postcode" t.string "postcod2" t.string "ppostc1" t.string "ppostc2" + t.integer "property_relet" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" end