Created
October 17, 2017 05:29
-
-
Save Ji-Yuhang/072bf7316b726d690f7915e5d2c75a15 to your computer and use it in GitHub Desktop.
pg_trgm gin postgre
This file contains hidden or 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
class AddPgTrgmExtensionToDb < ActiveRecord::Migration[5.0] | |
# def change | |
# # execute "remove extension pg_trgm;" | |
# execute "create extension IF NOT EXISTS pg_trgm;" | |
# execute "CREATE EXTENSION IF NOT EXISTS btree_gin;" | |
# | |
# remove_index :words, :word | |
# add_index :words, :word, using: :btree_gin | |
# end | |
def up | |
execute "create extension IF NOT EXISTS pg_trgm;" | |
execute "CREATE EXTENSION IF NOT EXISTS btree_gin;" | |
remove_index :words, :word if index_exists?(:words, :word) | |
add_index :words, :word, using: :gin | |
end | |
def down | |
execute "drop extension IF EXISTS pg_trgm;" | |
execute "drop EXTENSION IF EXISTS btree_gin;" | |
remove_index :words, :word if index_exists?(:words, :word) | |
# add_index :words, :word, using: :btree_gin | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment