eBooru/db/migrate/20230517155547_add_text_wildcard_search_index.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

20 lines
604 B
Ruby

# frozen_string_literal: true
class AddTextWildcardSearchIndex < ActiveRecord::Migration[7.0]
def up
add_gin_index :blips, :body
add_gin_index :comments, :body
add_gin_index :dmails, :body
add_gin_index :forum_posts, :body
add_gin_index :forum_topics, :title
add_gin_index :notes, :body
add_gin_index :user_feedback, :body
add_gin_index :wiki_pages, :body
add_gin_index :wiki_pages, :title
end
def add_gin_index(table, column)
execute("CREATE INDEX index_#{table}_on_lower_#{column}_trgm ON #{table} USING gin ((lower(#{column})) gin_trgm_ops)")
end
end