-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
1edfdb3
commit 7b615a2
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters