-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metadata: Lower case index to support case insensitive searching (#806)
* feat: update metadata index on attachments and samples to be on lowercase so that we can do case-insensitive searching * chore: rename index so that it includes _ci suffix to denote it as case insensitive * chore: add in test for case insensitive searching samples by metadata in graphql
- Loading branch information
Showing
4 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
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
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,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# Update metadata index for attachments and samples to be on lower case | ||
class UpdateMetadataIndexes < ActiveRecord::Migration[7.2] | ||
def change # rubocop:disable Metrics/MethodLength | ||
reversible do |dir| | ||
dir.up do | ||
execute <<~SQL.squish | ||
DROP INDEX index_attachments_on_metadata; | ||
CREATE INDEX index_attachments_on_metadata_ci ON attachments USING GIN ((LOWER(metadata::text)::jsonb)); | ||
DROP INDEX index_samples_on_metadata; | ||
CREATE INDEX index_samples_on_metadata_ci ON samples USING GIN ((LOWER(metadata::text)::jsonb)); | ||
SQL | ||
end | ||
|
||
dir.down do | ||
execute <<~SQL.squish | ||
DROP INDEX index_attachments_on_metadata_ci; | ||
DROP INDEX index_samples_on_metadata_ci; | ||
SQL | ||
add_index :attachments, :metadata, using: :gin | ||
add_index :samples, :metadata, using: :gin | ||
end | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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