From 57f0afe64835414df3bd51399464e36dbe323695 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 26 Jan 2022 13:36:13 +0000 Subject: [PATCH] Store rent and charges currency as decimal (#247) --- .../20220126101743_change_currency_types.rb | 39 +++++++++++++++++++ db/schema.rb | 16 ++++---- 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20220126101743_change_currency_types.rb diff --git a/db/migrate/20220126101743_change_currency_types.rb b/db/migrate/20220126101743_change_currency_types.rb new file mode 100644 index 000000000..433e96f87 --- /dev/null +++ b/db/migrate/20220126101743_change_currency_types.rb @@ -0,0 +1,39 @@ +class ChangeCurrencyTypes < ActiveRecord::Migration[7.0] + def up + change_table :case_logs, bulk: true do |t| + t.remove :brent + t.column :brent, :decimal, precision: 10, scale: 2 + t.remove :scharge + t.column :scharge, :decimal, precision: 10, scale: 2 + t.remove :pscharge + t.column :pscharge, :decimal, precision: 10, scale: 2 + t.remove :supcharg + t.column :supcharg, :decimal, precision: 10, scale: 2 + t.remove :tcharge + t.column :tcharge, :decimal, precision: 10, scale: 2 + t.remove :tshortfall + t.column :tshortfall, :decimal, precision: 10, scale: 2 + t.remove :chcharge + t.column :chcharge, :decimal, precision: 10, scale: 2 + end + end + + def down + change_table :case_logs, bulk: true do |t| + t.remove :brent + t.column :brent, :integer + t.remove :scharge + t.column :scharge, :integer + t.remove :pscharge + t.column :pscharge, :integer + t.remove :supcharg + t.column :supcharg, :integer + t.remove :tcharge + t.column :tcharge, :integer + t.remove :tshortfall + t.column :tshortfall, :integer + t.remove :chcharge + t.column :chcharge, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 52952738e..673208b27 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: 2022_01_24_121642) do +ActiveRecord::Schema.define(version: 2022_01_26_101743) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -177,14 +177,14 @@ ActiveRecord::Schema.define(version: 2022_01_24_121642) do t.integer "letting_in_sheltered_accomodation" t.integer "household_charge" t.integer "earnings" - t.integer "brent" - t.integer "scharge" - t.integer "pscharge" - t.integer "supcharg" - t.integer "tcharge" - t.integer "tshortfall" - t.integer "chcharge" t.integer "referral" + t.decimal "brent", precision: 10, scale: 2 + t.decimal "scharge", precision: 10, scale: 2 + t.decimal "pscharge", precision: 10, scale: 2 + t.decimal "supcharg", precision: 10, scale: 2 + t.decimal "tcharge", precision: 10, scale: 2 + t.decimal "tshortfall", precision: 10, scale: 2 + t.decimal "chcharge", precision: 10, scale: 2 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"