diff --git a/db/migrate/20230731140544_fix_samples_measured_signals.rb b/db/migrate/20230731140544_fix_samples_measured_signals.rb new file mode 100644 index 000000000..43e41c379 --- /dev/null +++ b/db/migrate/20230731140544_fix_samples_measured_signals.rb @@ -0,0 +1,17 @@ +class FixSamplesMeasuredSignals < ActiveRecord::Migration[5.0] + def up + # make sure measured signals are always a float (the entity framework + # deletes the attribute from the core_fields when it's nil): + Sample + .where("core_fields LIKE '%measured_signal%'") + .preload(:sample_identifiers) + .find_each do |sample| + sample.measured_signal = sample.measured_signal.presence&.to_f + sample.save(validate: false) + end + end + + def down + # nothing to do + end +end diff --git a/db/schema.rb b/db/schema.rb index e95e4b4d8..720fc7cea 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: 20221223203602) do +ActiveRecord::Schema.define(version: 20230731140544) do create_table "alert_condition_results", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci" do |t| t.string "result"