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,
"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,
}

1
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

35
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"
}
}
}

77
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

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

Loading…
Cancel
Save