2017-06-23 22:06:11 +08:00
|
|
|
require File.expand_path('app/helpers/database_helper')
|
|
|
|
include DatabaseHelper
|
|
|
|
|
2017-07-06 21:12:15 +08:00
|
|
|
class AddSearchIndexesToRepositories < ActiveRecord::Migration[4.2]
|
2017-06-23 22:06:11 +08:00
|
|
|
def up
|
|
|
|
if db_adapter_is? 'PostgreSQL'
|
|
|
|
if index_exists?(:repository_rows, :name)
|
|
|
|
remove_index :repository_rows, :name
|
|
|
|
end
|
|
|
|
add_gin_index_without_tags :repository_rows, :name
|
|
|
|
add_gin_index_without_tags :repository_text_values, :data
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
if db_adapter_is? 'PostgreSQL'
|
2017-06-27 19:23:51 +08:00
|
|
|
remove_index :repository_rows, :name
|
2017-06-23 22:06:11 +08:00
|
|
|
remove_index :repository_text_values, :data
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|