Add tsvector index to comments.body_markdown (#13469)
* Add tsvector index to comments.body_markdown * Users --> Comments
This commit is contained in:
parent
7c9a23fde2
commit
447a8ab908
2 changed files with 29 additions and 1 deletions
|
|
@ -0,0 +1,27 @@
|
|||
class AddBodyMarkdownTsvectorIndexToComments < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX = "to_tsvector('simple'::regconfig, COALESCE((body_markdown)::text, ''::text))"
|
||||
private_constant :INDEX
|
||||
|
||||
INDEX_NAME = "index_comments_on_body_markdown_as_tsvector"
|
||||
private_constant :INDEX_NAME
|
||||
|
||||
def up
|
||||
return if index_name_exists?(:comments, INDEX_NAME)
|
||||
|
||||
add_index :comments,
|
||||
INDEX,
|
||||
using: :gin,
|
||||
name: INDEX_NAME,
|
||||
algorithm: :concurrently
|
||||
end
|
||||
|
||||
def down
|
||||
return unless index_name_exists?(:comments, INDEX_NAME)
|
||||
|
||||
remove_index :comments,
|
||||
name: INDEX_NAME,
|
||||
algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_04_20_135208) do
|
||||
ActiveRecord::Schema.define(version: 2021_04_21_190438) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "citext"
|
||||
|
|
@ -388,6 +388,7 @@ ActiveRecord::Schema.define(version: 2021_04_20_135208) do
|
|||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id"
|
||||
t.index "digest(body_markdown, 'sha512'::text), user_id, ancestry, commentable_id, commentable_type", name: "index_comments_on_body_markdown_user_ancestry_commentable", unique: true
|
||||
t.index "to_tsvector('simple'::regconfig, COALESCE(body_markdown, ''::text))", name: "index_comments_on_body_markdown_as_tsvector", using: :gin
|
||||
t.index ["ancestry"], name: "index_comments_on_ancestry"
|
||||
t.index ["ancestry"], name: "index_comments_on_ancestry_trgm", opclass: :gin_trgm_ops, using: :gin
|
||||
t.index ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue