Skip to content

Commit

Permalink
Merge pull request #4601 from sanger/Y24-373-sample-metadata-correcti…
Browse files Browse the repository at this point in the history
…on-migration

Y24-373 - Sample Metadata migration to update invalid country_or_origin data
  • Loading branch information
BenTopping authored Jan 28, 2025
2 parents ba20bbf + 873a717 commit 75cf1c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2025_01_14_135342) do
ActiveRecord::Schema[7.0].define(version: 2025_01_23_105050) do
create_table "aliquot_indices", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.integer "aliquot_id", null: false
t.integer "lane_id", null: false
Expand Down

0 comments on commit 75cf1c5

Please sign in to comment.