-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4601 from sanger/Y24-373-sample-metadata-correcti…
…on-migration Y24-373 - Sample Metadata migration to update invalid country_or_origin data
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
db/migrate/20250123105050_migrate_sample_metadata_for_invalid_insdc_country_of_origin.rb
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 @@ | ||
# frozen_string_literal: true | ||
# Migrates the data related to invalid INSDC countries of origin to their current equivalent | ||
# See DisableInvalidInsdcCountries migration for more details | ||
class MigrateSampleMetadataForInvalidInsdcCountryOfOrigin < ActiveRecord::Migration[7.0] | ||
def change | ||
sample_metadata = | ||
Sample::Metadata.where(country_of_origin: ['not applicable: control sample', 'not applicable: sample group']) | ||
|
||
sample_metadata.each do |sm| | ||
if sm.country_of_origin == 'not applicable: control sample' | ||
sm.update!(country_of_origin: 'missing: control sample') | ||
elsif sm.country_of_origin == 'not applicable: sample group' | ||
sm.update!(country_of_origin: 'missing: sample group') | ||
end | ||
end | ||
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