-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: ensure that samples' measured signals are floats (#1981)
- Loading branch information
1 parent
4c45652
commit 0220550
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters