Browse Source

update miration and some mappings

pull/83/head
Kat 4 years ago
parent
commit
aeff1a69fc
  1. 2
      app/constants/db_enums.rb
  2. 1
      app/models/case_log.rb
  3. 35
      config/forms/2021_2022.json
  4. 77
      db/migrate/20211108134601_further_core_migrations.rb
  5. 21
      db/migrate/20211108143649_further_change_field_types.rb
  6. 20
      db/schema.rb

2
app/constants/db_enums.rb

@ -20,7 +20,7 @@ module DbEnums
"Not seeking work" => 6, "Not seeking work" => 6,
"Full-time student" => 7, "Full-time student" => 7,
"Unable to work because of long term sick or disability" => 8, "Unable to work because of long term sick or disability" => 8,
"Child under 16" => 100, "Child under 16" => 9,
"Other" => 0, "Other" => 0,
"Prefer not to say" => 10, "Prefer not to say" => 10,
} }

1
app/models/case_log.rb

@ -107,6 +107,7 @@ class CaseLog < ApplicationRecord
enum majorrepairs: DbEnums.polar, _suffix: true enum majorrepairs: DbEnums.polar, _suffix: true
enum hb: DbEnums.housing_benefit, _suffix: true enum hb: DbEnums.housing_benefit, _suffix: true
enum hbrentshortfall: DbEnums.polar_with_unknown, _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 AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze

35
config/forms/2021_2022.json

@ -273,24 +273,23 @@
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "UK national resident in UK", "0": "UK national resident in UK",
"1": "A current or former reserve in the UK Armed Forces (exc. National Service)", "1": "UK national returning from residence overseas",
"2": "UK national returning from residence overseas", "2": "Czech Republic",
"3": "Czech Republic", "3": "Estonia",
"4": "Estonia", "4": "Hungary",
"5": "Hungary", "5": "Latvia",
"6": "Latvia", "6": "Lithuania",
"7": "Lithuania", "7": "Poland",
"8": "Poland", "8": "Slovakia",
"9": "Slovakia", "9": "Bulgaria",
"10": "Bulgaria", "10": "Romania",
"11": "Romania", "11": "Ireland",
"12": "Ireland", "12": "Slovakia",
"13": "Slovakia", "13":"Slovenia",
"14":"Slovenia", "14": "Croatia",
"15": "Croatia", "15": "Other EU Economic Area (EEA country)",
"16": "Other EU Economic Area (EEA country)", "16": "Any other country",
"17": "Any other country", "17": "Prefer not to say"
"18": "Prefer not to say"
} }
} }
} }

77
db/migrate/20211108134601_further_core_migrations.rb

@ -1,33 +1,58 @@
class FurtherCoreMigrations < ActiveRecord::Migration[6.1] class FurtherCoreMigrations < ActiveRecord::Migration[6.1]
def up def up
remove_column :case_logs, :condition_effects_prefer_not_to_say change_table :case_logs, bulk: true do |t|
rename_column :case_logs, :reason_for_leaving_last_settled_home, :reason t.remove :condition_effects_prefer_not_to_say
rename_column :case_logs, :property_reference, :propcode t.remove :reason_for_leaving_last_settled_home
rename_column :case_logs, :property_major_repairs, :majorrepairs t.column :reason, :integer
rename_column :case_logs, :property_location, :la t.remove :property_reference
rename_column :case_logs, :previous_la, :prevloc t.column :propcode, :string
rename_column :case_logs, :housing_benefit, :hb t.remove :property_major_repairs
rename_column :case_logs, :outstanding_rent_or_charges, :hbrentshortfall t.column :majorrepairs, :integer
rename_column :case_logs, :outstanding_amount, :tshortfall t.remove :property_location
add_column :case_logs, :postcode, :string t.column :la, :string
add_column :case_logs, :postcod2, :string t.remove :previous_la
add_column :case_logs, :ppostc1, :string t.column :prevloc, :string
add_column :case_logs, :ppostc2, :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 end
def down def down
add_column :case_logs, :condition_effects_prefer_not_to_say, :integer change_table :case_logs, bulk: true do |t|
rename_column :case_logs, :reason, :reason_for_leaving_last_settled_home t.column :condition_effects_prefer_not_to_say, :integer
rename_column :case_logs, :propcode, :property_reference t.column :condition_effects_prefer_not_to_say, :integer
rename_column :case_logs, :majorrepairs, :property_major_repairs t.column :reason_for_leaving_last_settled_home, :string
rename_column :case_logs, :la, :property_location t.remove :reason
rename_column :case_logs, :prevloc, :previous_la t.column :property_reference, :string
rename_column :case_logs, :hb, :housing_benefit t.remove :propcode
rename_column :case_logs, :hbrentshortfall, :outstanding_rent_or_charges t.column :property_major_repairs, :string
rename_column :case_logs, :tshortfall, :outstanding_amount t.remove :majorrepairs
remove_column :case_logs, :postcode t.column :property_location, :string
remove_column :case_logs, :postcod2 t.remove :la
remove_column :case_logs, :ppostc1 t.column :previous_la, :string
remove_column :case_logs, :ppostc2 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
end end

21
db/migrate/20211108143649_further_change_field_types.rb

@ -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

20
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -57,7 +57,6 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do
t.string "sex8" t.string "sex8"
t.integer "ecstat8" t.integer "ecstat8"
t.integer "homeless" t.integer "homeless"
t.integer "reason"
t.integer "underoccupation_benefitcap" t.integer "underoccupation_benefitcap"
t.integer "leftreg" t.integer "leftreg"
t.integer "reservist" t.integer "reservist"
@ -73,40 +72,32 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do
t.integer "tenancy" t.integer "tenancy"
t.string "lettype" t.string "lettype"
t.integer "landlord" t.integer "landlord"
t.string "la"
t.string "previous_postcode" t.string "previous_postcode"
t.string "property_relet"
t.integer "rsnvac" t.integer "rsnvac"
t.string "propcode"
t.integer "unittype_gn" t.integer "unittype_gn"
t.string "property_building_type" t.string "property_building_type"
t.integer "beds" t.integer "beds"
t.string "property_void_date" t.string "property_void_date"
t.integer "majorrepairs"
t.string "property_major_repairs_date" t.string "property_major_repairs_date"
t.integer "offered" t.integer "offered"
t.integer "wchair" t.integer "wchair"
t.integer "earnings" t.integer "earnings"
t.integer "incfreq" t.integer "incfreq"
t.integer "benefits" t.integer "benefits"
t.integer "hb"
t.integer "period" t.integer "period"
t.integer "brent" t.integer "brent"
t.integer "scharge" t.integer "scharge"
t.integer "pscharge" t.integer "pscharge"
t.integer "supcharg" t.integer "supcharg"
t.integer "tcharge" t.integer "tcharge"
t.integer "tshortfall"
t.integer "layear" t.integer "layear"
t.integer "lawaitlist" t.integer "lawaitlist"
t.string "prevloc"
t.string "property_postcode" t.string "property_postcode"
t.integer "reasonpref" t.integer "reasonpref"
t.string "reasonable_preference_reason" t.string "reasonable_preference_reason"
t.integer "cbl" t.integer "cbl"
t.integer "chr" t.integer "chr"
t.integer "cap" t.integer "cap"
t.integer "hbrentshortfall"
t.string "other_reason_for_leaving_last_settled_home" t.string "other_reason_for_leaving_last_settled_home"
t.integer "housingneeds_a" t.integer "housingneeds_a"
t.integer "housingneeds_b" t.integer "housingneeds_b"
@ -145,10 +136,19 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do
t.string "needs_type" t.string "needs_type"
t.string "sale_completion_date" t.string "sale_completion_date"
t.string "purchaser_code" 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 "postcode"
t.string "postcod2" t.string "postcod2"
t.string "ppostc1" t.string "ppostc1"
t.string "ppostc2" t.string "ppostc2"
t.integer "property_relet"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end end

Loading…
Cancel
Save