From a4c72b98bf186309c101e90f83d7a94b696f6aac Mon Sep 17 00:00:00 2001 From: Mounika Myana <173168271+mounikamy@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:51:49 -0500 Subject: [PATCH] Update migrations to support Rails upgrade (#23534) Co-authored-by: mounikamy --- .../20240507145931_add_columns_to_transcriptions.rb | 2 +- .../20240507203310_add_indexes_to_transcriptions.rb | 2 +- ...240520161059_add_transcription_packages_table.rb | 2 +- ...3021417_update_transcription_packages_columns.rb | 2 +- ...index_to_transcription_packages_contractor_id.rb | 6 ++++++ ...241118075353_update_indexes_on_transcriptions.rb | 13 +++++++++++++ db/schema.rb | 7 ++++--- 7 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20241118071918_add_index_to_transcription_packages_contractor_id.rb create mode 100644 db/migrate/20241118075353_update_indexes_on_transcriptions.rb diff --git a/db/migrate/20240507145931_add_columns_to_transcriptions.rb b/db/migrate/20240507145931_add_columns_to_transcriptions.rb index 21af1359c55..a55f96c3936 100644 --- a/db/migrate/20240507145931_add_columns_to_transcriptions.rb +++ b/db/migrate/20240507145931_add_columns_to_transcriptions.rb @@ -1,4 +1,4 @@ -class AddColumnsToTranscriptions < Caseflow::Migration +class AddColumnsToTranscriptions < ActiveRecord::Migration[6.1] def change add_column :transcriptions, :transcription_contractor_id, :bigint add_column :transcriptions, :created_by_id, :bigint diff --git a/db/migrate/20240507203310_add_indexes_to_transcriptions.rb b/db/migrate/20240507203310_add_indexes_to_transcriptions.rb index 309d0b908a4..b1b795c186e 100644 --- a/db/migrate/20240507203310_add_indexes_to_transcriptions.rb +++ b/db/migrate/20240507203310_add_indexes_to_transcriptions.rb @@ -1,4 +1,4 @@ -class AddIndexesToTranscriptions < Caseflow::Migration +class AddIndexesToTranscriptions < ActiveRecord::Migration[6.1] def change add_safe_index :transcriptions, [:transcription_contractor_id], name: "index_transcriptions_on_transcription_contractor_id" add_safe_index :transcriptions, [:deleted_at], name: "index_transcriptions_on_deleted_at" diff --git a/db/migrate/20240520161059_add_transcription_packages_table.rb b/db/migrate/20240520161059_add_transcription_packages_table.rb index 04a86adc568..c3915651ec7 100644 --- a/db/migrate/20240520161059_add_transcription_packages_table.rb +++ b/db/migrate/20240520161059_add_transcription_packages_table.rb @@ -1,4 +1,4 @@ -class AddTranscriptionPackagesTable < Caseflow::Migration +class AddTranscriptionPackagesTable < ActiveRecord::Migration[6.1] def change create_table :transcription_packages do |t| t.string :aws_link_zip, comment: "Link of where the file is in AWS S3 (transcription_text) for the return work order" diff --git a/db/migrate/20240523021417_update_transcription_packages_columns.rb b/db/migrate/20240523021417_update_transcription_packages_columns.rb index b05f50e9ea2..52c8a37f44a 100644 --- a/db/migrate/20240523021417_update_transcription_packages_columns.rb +++ b/db/migrate/20240523021417_update_transcription_packages_columns.rb @@ -1,4 +1,4 @@ -class UpdateTranscriptionPackagesColumns < Caseflow::Migration +class UpdateTranscriptionPackagesColumns < ActiveRecord::Migration[6.1] def change add_column :transcription_packages, :date_upload_box, :datetime, comment: "Date of successful delivery to box.com contractor endpoint" diff --git a/db/migrate/20241118071918_add_index_to_transcription_packages_contractor_id.rb b/db/migrate/20241118071918_add_index_to_transcription_packages_contractor_id.rb new file mode 100644 index 00000000000..1a9b837ea47 --- /dev/null +++ b/db/migrate/20241118071918_add_index_to_transcription_packages_contractor_id.rb @@ -0,0 +1,6 @@ +class AddIndexToTranscriptionPackagesContractorId < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + def change + add_index :transcription_packages, :contractor_id, name: "index_transcription_packages_on_contractor_id", algorithm: :concurrently + end +end diff --git a/db/migrate/20241118075353_update_indexes_on_transcriptions.rb b/db/migrate/20241118075353_update_indexes_on_transcriptions.rb new file mode 100644 index 00000000000..d3dbefcc095 --- /dev/null +++ b/db/migrate/20241118075353_update_indexes_on_transcriptions.rb @@ -0,0 +1,13 @@ +class UpdateIndexesOnTranscriptions < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def change + unless index_exists?(:transcriptions, :transcription_contractor_id, name: "index_transcriptions_on_transcription_contractor_id") + add_index :transcriptions, :transcription_contractor_id, name: "index_transcriptions_on_transcription_contractor_id",algorithm: :concurrently + end + + unless index_exists?(:transcriptions, :deleted_at, name: "index_transcriptions_on_deleted_at") + add_index :transcriptions, :deleted_at, name: "index_transcriptions_on_deleted_at",algorithm: :concurrently + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a054b840b36..70d3f15362f 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.define(version: 2024_10_12_181521) do +ActiveRecord::Schema.define(version: 2024_11_18_075353) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1763,12 +1763,12 @@ create_table "returned_appeal_jobs", force: :cascade do |t| t.datetime "completed_at" - t.datetime "created_at", null: false + t.datetime "created_at", precision: 6, null: false t.datetime "errored_at" t.text "returned_appeals", default: [], array: true t.datetime "started_at" t.json "stats" - t.datetime "updated_at", null: false + t.datetime "updated_at", precision: 6, null: false end create_table "schedule_periods", force: :cascade do |t| @@ -2054,6 +2054,7 @@ t.string "task_number", comment: "Number associated with transcription, use as FK to transcriptions" t.datetime "updated_at" t.bigint "updated_by_id", comment: "The user who most recently updated the transcription file" + t.index ["contractor_id"], name: "index_transcription_packages_on_contractor_id" t.index ["task_number"], name: "index_transcription_packages_on_task_number" end