Skip to content

Commit c98325c

Browse files
committed
Remove pds search results index
This index restricts the PDS searches to only be able to run once per import/patient combo. We don't particularly need this protection, and as it turns out when we merge two patients this breaks because we try to merge their search results too.
1 parent c2d33ae commit c98325c

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

app/models/pds_search_result.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#
1717
# Indexes
1818
#
19-
# index_pds_search_results_on_import (import_type,import_id)
20-
# index_pds_search_results_on_patient_id (patient_id)
21-
# index_pds_search_results_on_patient_import_step (patient_id,import_type,import_id,step) UNIQUE
19+
# index_pds_search_results_on_import (import_type,import_id)
20+
# index_pds_search_results_on_patient_id (patient_id)
2221
#
2322
# Foreign Keys
2423
#
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveIndexPDSSearchResultsOnPatientImportStep < ActiveRecord::Migration[
4+
8.0
5+
]
6+
def change
7+
remove_index :pds_search_results,
8+
name: "index_pds_search_results_on_patient_import_step",
9+
column: %i[patient_id import_type import_id step],
10+
unique: true
11+
end
12+
end

db/schema.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[8.0].define(version: 2025_08_22_094829) do
13+
ActiveRecord::Schema[8.0].define(version: 2025_08_26_135132) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_catalog.plpgsql"
1616
enable_extension "pg_trgm"
@@ -718,7 +718,6 @@
718718
t.datetime "created_at", null: false
719719
t.datetime "updated_at", null: false
720720
t.index ["import_type", "import_id"], name: "index_pds_search_results_on_import"
721-
t.index ["patient_id", "import_type", "import_id", "step"], name: "index_pds_search_results_on_patient_import_step", unique: true
722721
t.index ["patient_id"], name: "index_pds_search_results_on_patient_id"
723722
end
724723

spec/factories/pds_search_results.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#
1717
# Indexes
1818
#
19-
# index_pds_search_results_on_import (import_type,import_id)
20-
# index_pds_search_results_on_patient_id (patient_id)
21-
# index_pds_search_results_on_patient_import_step (patient_id,import_type,import_id,step) UNIQUE
19+
# index_pds_search_results_on_import (import_type,import_id)
20+
# index_pds_search_results_on_patient_id (patient_id)
2221
#
2322
# Foreign Keys
2423
#

0 commit comments

Comments
 (0)