Skip to content

Commit 7b615a2

Browse files
bkiahstroudjeremyf
andauthored
Index :bulkrax_identifier metadata in :orm_resources (#946)
* index :bulkrax_identifier metadata in :orm_resources * Bumping schema based on migrations --------- Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
1 parent 1edfdb3 commit 7b615a2

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class AddIndexToMetadataBulkraxIdentifier < ActiveRecord::Migration[6.1]
2+
def up
3+
return unless table_exists?(:orm_resources)
4+
return if index_exists?(:orm_resources, "(((metadata -> 'bulkrax_identifier'::text) ->> 0))", name: 'index_on_bulkrax_identifier')
5+
6+
# This creates an expression index on the first element of the bulkrax_identifier array
7+
add_index :orm_resources,
8+
"(metadata -> 'bulkrax_identifier' ->> 0)",
9+
name: 'index_on_bulkrax_identifier',
10+
where: "metadata -> 'bulkrax_identifier' IS NOT NULL"
11+
end
12+
13+
def down
14+
return unless table_exists?(:orm_resources)
15+
16+
remove_index :orm_resources, name: 'index_on_bulkrax_identifier'
17+
end
18+
end

spec/test_app/db/schema.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@
101101
t.integer "total_file_set_entries", default: 0
102102
t.integer "processed_works", default: 0
103103
t.integer "failed_works", default: 0
104-
t.integer "processed_children", default: 0
105-
t.integer "failed_children", default: 0
106104
t.index ["importer_id"], name: "index_bulkrax_importer_runs_on_importer_id"
107105
end
108106

@@ -646,4 +644,14 @@
646644
t.index ["work_id"], name: "index_work_view_stats_on_work_id"
647645
end
648646

647+
add_foreign_key "bulkrax_exporter_runs", "bulkrax_exporters", column: "exporter_id"
648+
add_foreign_key "bulkrax_importer_runs", "bulkrax_importers", column: "importer_id"
649+
add_foreign_key "bulkrax_pending_relationships", "bulkrax_importer_runs", column: "importer_run_id"
650+
add_foreign_key "collection_type_participants", "hyrax_collection_types"
651+
add_foreign_key "curation_concerns_operations", "users"
652+
add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id"
653+
add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id"
654+
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id"
655+
add_foreign_key "permission_template_accesses", "permission_templates"
656+
add_foreign_key "uploaded_files", "users"
649657
end

0 commit comments

Comments
 (0)