Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate 'sample_public_name' column values with 'sanger_sample_id' column values for RVI-prefixed samples #4565

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true
class UpdateSamplePublicNameForRviStudy < ActiveRecord::Migration[7.0]
def change
ActiveRecord::Base.connection.execute('SET autocommit = 0')
ActiveRecord::Base.connection.execute(<<~SQLQUERY)

UPDATE sample_metadata
JOIN samples ON sample_metadata.sample_id = samples.id
JOIN study_samples ON sample_metadata.sample_id = study_samples.sample_id
JOIN studies ON study_samples.study_id = studies.id
SET sample_metadata.sample_public_name = samples.sanger_sample_id
WHERE studies.name = 'RVI Program - Bait Capture' AND sanger_sample_id LIKE 'RVI%';
SQLQUERY

ActiveRecord::Base.connection.execute('COMMIT')
ActiveRecord::Base.connection.execute('SET autocommit = 1')
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: 2024_11_06_103710) do
ActiveRecord::Schema[7.0].define(version: 2024_12_17_140910) 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
Loading