From 06355bff762f9943ca934154f7668fff82f602cb Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 1 Dec 2021 13:36:27 +0000 Subject: [PATCH] Run migrations --- app/constants/db_enums.rb | 7 ++++++ app/models/case_log.rb | 1 + config/forms/2021_2022.json | 22 +------------------ ...1201114814_change_lettype_derived_field.rb | 19 ++++++++++++++++ db/schema.rb | 8 +++---- spec/factories/case_log.rb | 2 +- spec/fixtures/complete_case_log.json | 2 +- 7 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 db/migrate/20211201114814_change_lettype_derived_field.rb diff --git a/app/constants/db_enums.rb b/app/constants/db_enums.rb index 0dc271baf..2a65aa984 100644 --- a/app/constants/db_enums.rb +++ b/app/constants/db_enums.rb @@ -733,4 +733,11 @@ module DbEnums "Intermediate Rent" => 3, } end + + def self.needstype + { + "General Needs" => 1, + "Supported Housing" => 2, + } + end end diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 478626381..e792d40c7 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -110,6 +110,7 @@ class CaseLog < ApplicationRecord enum builtype: DbEnums.builtype, _suffix: true enum incref: DbEnums.polar, _suffix: true enum renttype: DbEnums.renttype, _suffix: true + enum needstype: DbEnums.needstype, _suffix: true AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at renttype].freeze OPTIONAL_FIELDS = %w[do_you_know_the_postcode diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 0ef875dc1..34af5078f 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -133,7 +133,7 @@ "header": "What is intermediate rent product name?", "type": "text" }, - "needs_type": { + "needstype": { "check_answer_label": "What is the needs type?", "header": "What is the needs type?", "hint_text": "", @@ -1065,26 +1065,6 @@ } } }, - "letting_type": { - "header": "", - "description": "", - "questions": { - "lettype": { - "check_answer_label": "Type of letting", - "header": "Which type of letting is this?", - "hint_text": "", - "type": "radio", - "answer_options": { - "0": "Social Rent - General Needs", - "1": "Social Rent - Supporting Housing", - "2": "Affordable Rent - General Needs", - "3": "Affordable Rent - Supporting Housing", - "4": "Rent To Buy - General Needs", - "5": "Rent To Buy - Supported Housing" - } - } - } - }, "letting_provider": { "header": "", "description": "", diff --git a/db/migrate/20211201114814_change_lettype_derived_field.rb b/db/migrate/20211201114814_change_lettype_derived_field.rb new file mode 100644 index 000000000..f9dc2f4ba --- /dev/null +++ b/db/migrate/20211201114814_change_lettype_derived_field.rb @@ -0,0 +1,19 @@ +class ChangeLettypeDerivedField < ActiveRecord::Migration[6.1] + def up + change_table :case_logs, bulk: true do |t| + t.remove :needs_type + t.column :needstype, :integer + t.remove :lettype + t.column :lettype, :integer + end + end + + def down + change_table :case_logs, bulk: true do |t| + t.column :needs_type, :string + t.remove :needstype + t.remove :lettype + t.column :lettype, :string + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d31322f7c..ce175dafd 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_30_144840) do +ActiveRecord::Schema.define(version: 2021_12_01_114814) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -77,7 +77,6 @@ ActiveRecord::Schema.define(version: 2021_11_30_144840) do t.integer "startertenancy" t.integer "tenancylength" t.integer "tenancy" - t.string "lettype" t.integer "landlord" t.string "previous_postcode" t.integer "rsnvac" @@ -137,7 +136,6 @@ ActiveRecord::Schema.define(version: 2021_11_30_144840) do t.string "tenant_same_property_renewal" t.string "rent_type" t.string "intermediate_rent_product_name" - t.string "needs_type" t.string "purchaser_code" t.integer "reason" t.string "propcode" @@ -165,10 +163,12 @@ ActiveRecord::Schema.define(version: 2021_11_30_144840) do t.string "why_dont_you_know_la" t.integer "unitletas" t.integer "builtype" + t.datetime "property_void_date" t.bigint "owning_organisation_id" t.bigint "managing_organisation_id" - t.datetime "property_void_date" t.integer "renttype" + t.integer "needstype" + t.integer "lettype" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id" diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index dd636f9d9..9c8b7434a 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -113,7 +113,7 @@ FactoryBot.define do tenant_same_property_renewal { 1 } rent_type { 1 } intermediate_rent_product_name { 2 } - needs_type { 1 } + needstype { 1 } purchaser_code { 798_794 } reason { "Permanently decanted from another property owned by this landlord" } propcode { "123" } diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index a01ae395a..8db69eb6e 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -128,7 +128,7 @@ "sale_or_letting": "", "rent_type": "", "intermediate_rent_product_name": "", - "needs_type": "", + "needstype": "", "sale_completion_date": "01/01/2020", "purchaser_code": "", "propcode": "123",