From 5edf5d33c0f88ae6db74443b8d9b539cb327dffc Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Wed, 28 Feb 2024 14:06:06 +0000 Subject: [PATCH 1/4] Adding the migrations for comment change --- ...pdate_iseq_flowcell_entity_type_comment.rb | 5 +++ db/schema.rb | 4 +-- db/views_schema.rb | 33 +------------------ 3 files changed, 8 insertions(+), 34 deletions(-) create mode 100644 db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb diff --git a/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb b/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb new file mode 100644 index 00000000..3db8440b --- /dev/null +++ b/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb @@ -0,0 +1,5 @@ +class UpdateIseqFlowcellEntityTypeComment < ActiveRecord::Migration[7.0] + def change + change_column_comment :iseq_flowcell, :entity_type, "Lane type: library, library_control, library_indexed, library_indexed_spike." + end +end diff --git a/db/schema.rb b/db/schema.rb index 5ce766f3..933deec5 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[7.0].define(version: 2023_12_07_143456) do +ActiveRecord::Schema[7.0].define(version: 2024_02_28_140011) do create_table "bmap_flowcell", primary_key: "id_bmap_flowcell_tmp", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t| t.datetime "last_updated", precision: nil, null: false, comment: "Timestamp of last update" t.datetime "recorded_at", precision: nil, null: false, comment: "Timestamp of warehouse update" @@ -67,7 +67,7 @@ t.string "reagent_kit_barcode", limit: 30, comment: "The barcode for the reagent kit or cartridge" t.string "id_flowcell_lims", limit: 20, null: false, comment: "LIMs-specific flowcell id, batch_id for Sequencescape" t.integer "position", limit: 2, null: false, comment: "Flowcell lane number", unsigned: true - t.string "entity_type", limit: 30, null: false, comment: "Lane type: library, pool, library_control, library_indexed, library_indexed_spike" + t.string "entity_type", limit: 30, null: false, comment: "Lane type: library, library_control, library_indexed, library_indexed_spike." t.string "entity_id_lims", limit: 20, null: false, comment: "Most specific LIMs identifier associated with this lane or plex or spike" t.integer "tag_index", limit: 2, comment: "Tag index, NULL if lane is not a pool", unsigned: true t.string "tag_sequence", limit: 30, comment: "Tag sequence" diff --git a/db/views_schema.rb b/db/views_schema.rb index 45349fdd..28a7ac3d 100644 --- a/db/views_schema.rb +++ b/db/views_schema.rb @@ -1,32 +1 @@ -mlwh_wh_db = Rails.configuration.view_schema_mlwh_db -event_wh_db = Rails.configuration.view_schema_ewh_db - -ViewsSchema.update_view( - 'cherrypicked_samples', - <<~SQL.squish - SELECT mlwh_sample.description AS 'root_sample_id', mlwh_stock_resource.labware_human_barcode AS 'plate_barcode', - mlwh_sample.phenotype AS 'phenotype', mlwh_stock_resource.labware_coordinate AS 'coordinate', - mlwh_sample.created AS 'created', 'Tecan' as 'robot_type' - FROM #{mlwh_wh_db}.`sample` AS mlwh_sample - JOIN #{mlwh_wh_db}.stock_resource AS mlwh_stock_resource ON (mlwh_sample.id_sample_tmp = mlwh_stock_resource.id_sample_tmp) - JOIN #{event_wh_db}.subjects mlwh_events_subjects ON (mlwh_events_subjects.friendly_name = mlwh_sample.sanger_sample_id) - JOIN #{event_wh_db}.roles mlwh_events_roles ON (mlwh_events_roles.subject_id = mlwh_events_subjects.id) - JOIN #{event_wh_db}.events mlwh_events_events ON (mlwh_events_roles.event_id = mlwh_events_events.id) - JOIN #{event_wh_db}.event_types mlwh_events_event_types ON (mlwh_events_events.event_type_id = mlwh_events_event_types.id) - WHERE mlwh_events_event_types.key = 'cherrypick_layout_set' - UNION - SELECT mlwh_sample.description AS 'root_sample_id', mlwh_lh_sample.plate_barcode AS 'plate_barcode', - mlwh_sample.phenotype AS 'phenotype', mlwh_lh_sample.coordinate AS 'coordinate', mlwh_sample.created AS 'created', - IF(mlwh_events_event_types.key="lh_beckman_cp_destination_created","Beckman","Biosero") AS 'robot_type' - FROM #{mlwh_wh_db}.sample as mlwh_sample - JOIN #{mlwh_wh_db}.lighthouse_sample AS mlwh_lh_sample ON (mlwh_sample.uuid_sample_lims = mlwh_lh_sample.lh_sample_uuid) - JOIN #{event_wh_db}.subjects AS mlwh_events_subjects ON (mlwh_events_subjects.uuid = UNHEX(REPLACE(mlwh_lh_sample.lh_sample_uuid, '-', ''))) - JOIN #{event_wh_db}.roles AS mlwh_events_roles ON (mlwh_events_roles.subject_id = mlwh_events_subjects.id) - JOIN #{event_wh_db}.events AS mlwh_events_events ON (mlwh_events_events.id = mlwh_events_roles.event_id) - JOIN #{event_wh_db}.event_types AS mlwh_events_event_types ON (mlwh_events_event_types.id = mlwh_events_events.event_type_id) - WHERE mlwh_events_event_types.key IN ( - 'lh_beckman_cp_destination_created', 'lh_biosero_cp_destination_plate_completed', 'lh_biosero_cp_destination_plate_partial_completed', - 'lh_biosero_cp_error_recovered_destination_plate_completed','lh_biosero_cp_error_recovered_destination_plate_partial_completed' - ) -SQL -) +# This is an automatically generated file by rake:db:views:dump_schema From a5fce89c2c16085fa58f0715d5b949aaaecae739 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Wed, 28 Feb 2024 14:09:30 +0000 Subject: [PATCH 2/4] Adding back the views update --- db/views_schema.rb | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/db/views_schema.rb b/db/views_schema.rb index 28a7ac3d..45349fdd 100644 --- a/db/views_schema.rb +++ b/db/views_schema.rb @@ -1 +1,32 @@ -# This is an automatically generated file by rake:db:views:dump_schema +mlwh_wh_db = Rails.configuration.view_schema_mlwh_db +event_wh_db = Rails.configuration.view_schema_ewh_db + +ViewsSchema.update_view( + 'cherrypicked_samples', + <<~SQL.squish + SELECT mlwh_sample.description AS 'root_sample_id', mlwh_stock_resource.labware_human_barcode AS 'plate_barcode', + mlwh_sample.phenotype AS 'phenotype', mlwh_stock_resource.labware_coordinate AS 'coordinate', + mlwh_sample.created AS 'created', 'Tecan' as 'robot_type' + FROM #{mlwh_wh_db}.`sample` AS mlwh_sample + JOIN #{mlwh_wh_db}.stock_resource AS mlwh_stock_resource ON (mlwh_sample.id_sample_tmp = mlwh_stock_resource.id_sample_tmp) + JOIN #{event_wh_db}.subjects mlwh_events_subjects ON (mlwh_events_subjects.friendly_name = mlwh_sample.sanger_sample_id) + JOIN #{event_wh_db}.roles mlwh_events_roles ON (mlwh_events_roles.subject_id = mlwh_events_subjects.id) + JOIN #{event_wh_db}.events mlwh_events_events ON (mlwh_events_roles.event_id = mlwh_events_events.id) + JOIN #{event_wh_db}.event_types mlwh_events_event_types ON (mlwh_events_events.event_type_id = mlwh_events_event_types.id) + WHERE mlwh_events_event_types.key = 'cherrypick_layout_set' + UNION + SELECT mlwh_sample.description AS 'root_sample_id', mlwh_lh_sample.plate_barcode AS 'plate_barcode', + mlwh_sample.phenotype AS 'phenotype', mlwh_lh_sample.coordinate AS 'coordinate', mlwh_sample.created AS 'created', + IF(mlwh_events_event_types.key="lh_beckman_cp_destination_created","Beckman","Biosero") AS 'robot_type' + FROM #{mlwh_wh_db}.sample as mlwh_sample + JOIN #{mlwh_wh_db}.lighthouse_sample AS mlwh_lh_sample ON (mlwh_sample.uuid_sample_lims = mlwh_lh_sample.lh_sample_uuid) + JOIN #{event_wh_db}.subjects AS mlwh_events_subjects ON (mlwh_events_subjects.uuid = UNHEX(REPLACE(mlwh_lh_sample.lh_sample_uuid, '-', ''))) + JOIN #{event_wh_db}.roles AS mlwh_events_roles ON (mlwh_events_roles.subject_id = mlwh_events_subjects.id) + JOIN #{event_wh_db}.events AS mlwh_events_events ON (mlwh_events_events.id = mlwh_events_roles.event_id) + JOIN #{event_wh_db}.event_types AS mlwh_events_event_types ON (mlwh_events_event_types.id = mlwh_events_events.event_type_id) + WHERE mlwh_events_event_types.key IN ( + 'lh_beckman_cp_destination_created', 'lh_biosero_cp_destination_plate_completed', 'lh_biosero_cp_destination_plate_partial_completed', + 'lh_biosero_cp_error_recovered_destination_plate_completed','lh_biosero_cp_error_recovered_destination_plate_partial_completed' + ) +SQL +) From 9a14706f754a0fdad79d8119ed8f3841dadd6208 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Wed, 28 Feb 2024 14:19:15 +0000 Subject: [PATCH 3/4] Updating the migration to up-down execution (up for updating, down for rolling back) --- ...0228140011_update_iseq_flowcell_entity_type_comment.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb b/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb index 3db8440b..e4d8c63b 100644 --- a/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb +++ b/db/migrate/20240228140011_update_iseq_flowcell_entity_type_comment.rb @@ -1,5 +1,9 @@ class UpdateIseqFlowcellEntityTypeComment < ActiveRecord::Migration[7.0] - def change - change_column_comment :iseq_flowcell, :entity_type, "Lane type: library, library_control, library_indexed, library_indexed_spike." + def up + change_column_comment :iseq_flowcell, :entity_type, "Lane type: library, library_control, library_indexed, library_indexed_spike" + end + + def down + change_column_comment :iseq_flowcell, :entity_type, "Lane type: library, pool, library_control, library_indexed, library_indexed_spike" end end From c30b5c3bea5a42b908d358405cf5c43e8adfc300 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Wed, 28 Feb 2024 14:24:13 +0000 Subject: [PATCH 4/4] Update to remove ful stop --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 933deec5..280d2c1a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -67,7 +67,7 @@ t.string "reagent_kit_barcode", limit: 30, comment: "The barcode for the reagent kit or cartridge" t.string "id_flowcell_lims", limit: 20, null: false, comment: "LIMs-specific flowcell id, batch_id for Sequencescape" t.integer "position", limit: 2, null: false, comment: "Flowcell lane number", unsigned: true - t.string "entity_type", limit: 30, null: false, comment: "Lane type: library, library_control, library_indexed, library_indexed_spike." + t.string "entity_type", limit: 30, null: false, comment: "Lane type: library, library_control, library_indexed, library_indexed_spike" t.string "entity_id_lims", limit: 20, null: false, comment: "Most specific LIMs identifier associated with this lane or plex or spike" t.integer "tag_index", limit: 2, comment: "Tag index, NULL if lane is not a pool", unsigned: true t.string "tag_sequence", limit: 30, comment: "Tag sequence"