Skip to content

Commit

Permalink
Index :bulkrax_identifier metadata in :orm_resources (#946)
Browse files Browse the repository at this point in the history
* index :bulkrax_identifier metadata in :orm_resources

* Bumping schema based on migrations

---------

Co-authored-by: Jeremy Friesen <[email protected]>
  • Loading branch information
bkiahstroud and jeremyf authored Mar 29, 2024
1 parent 1edfdb3 commit 7b615a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class AddIndexToMetadataBulkraxIdentifier < ActiveRecord::Migration[6.1]
def up
return unless table_exists?(:orm_resources)
return if index_exists?(:orm_resources, "(((metadata -> 'bulkrax_identifier'::text) ->> 0))", name: 'index_on_bulkrax_identifier')

# This creates an expression index on the first element of the bulkrax_identifier array
add_index :orm_resources,
"(metadata -> 'bulkrax_identifier' ->> 0)",
name: 'index_on_bulkrax_identifier',
where: "metadata -> 'bulkrax_identifier' IS NOT NULL"
end

def down
return unless table_exists?(:orm_resources)

remove_index :orm_resources, name: 'index_on_bulkrax_identifier'
end
end
12 changes: 10 additions & 2 deletions spec/test_app/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@
t.integer "total_file_set_entries", default: 0
t.integer "processed_works", default: 0
t.integer "failed_works", default: 0
t.integer "processed_children", default: 0
t.integer "failed_children", default: 0
t.index ["importer_id"], name: "index_bulkrax_importer_runs_on_importer_id"
end

Expand Down Expand Up @@ -646,4 +644,14 @@
t.index ["work_id"], name: "index_work_view_stats_on_work_id"
end

add_foreign_key "bulkrax_exporter_runs", "bulkrax_exporters", column: "exporter_id"
add_foreign_key "bulkrax_importer_runs", "bulkrax_importers", column: "importer_id"
add_foreign_key "bulkrax_pending_relationships", "bulkrax_importer_runs", column: "importer_run_id"
add_foreign_key "collection_type_participants", "hyrax_collection_types"
add_foreign_key "curation_concerns_operations", "users"
add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id"
add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id"
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id"
add_foreign_key "permission_template_accesses", "permission_templates"
add_foreign_key "uploaded_files", "users"
end

0 comments on commit 7b615a2

Please sign in to comment.