diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index f546ea56d..702dcb599 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -26,12 +26,14 @@ class BulkUpload else data_range = FIRST_DATA_ROW..last_row data_range.map do |row_num| - case_log = CaseLog.create + case_log = CaseLog.create! map_row(sheet.row(row_num)).each do |attr_key, attr_val| - begin - case_log.update_attribute(attr_key, attr_val) - rescue ArgumentError + update = case_log.update(attr_key => attr_val) + unless update.persisted? + # TODO: determine what to do when a bulk upload contains field values that don't pass validations end + rescue ArgumentError + # TODO: determine what we want to do when bulk upload contains totally invalid data for a field. end end end diff --git a/db/migrate/20211116102527_change_datetime.rb b/db/migrate/20211116102527_change_datetime.rb index f3b78282b..10a9c581f 100644 --- a/db/migrate/20211116102527_change_datetime.rb +++ b/db/migrate/20211116102527_change_datetime.rb @@ -1,5 +1,5 @@ class ChangeDatetime < ActiveRecord::Migration[6.1] - def change + def up change_table :case_logs, bulk: true do |t| t.remove :sale_completion_date t.column :sale_completion_date, :datetime @@ -7,4 +7,13 @@ class ChangeDatetime < ActiveRecord::Migration[6.1] t.column :startdate, :datetime end end + + def down + change_table :case_logs, bulk: true do |t| + t.remove :sale_completion_date + t.column :sale_completion_date, :string + t.remove :startdate + t.column :startdate, :string + end + end end diff --git a/db/schema.rb b/db/schema.rb index fa2839c20..b011b0ce8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -121,6 +121,8 @@ ActiveRecord::Schema.define(version: 2021_11_16_102527) do t.integer "rp_dontknow" t.datetime "discarded_at" t.string "tenancyother" + t.integer "override_net_income_validation" + t.string "net_income_known" t.string "gdpr_acceptance" t.string "gdpr_declined" t.string "property_owner_organisation" @@ -131,8 +133,6 @@ ActiveRecord::Schema.define(version: 2021_11_16_102527) do t.string "intermediate_rent_product_name" t.string "needs_type" t.string "purchaser_code" - t.integer "override_net_income_validation" - t.string "net_income_known" t.integer "reason" t.string "propcode" t.integer "majorrepairs"