Index redirect_routes path for LIKE
This commit is contained in:
parent
4da848ef28
commit
03144e1c0f
3 changed files with 31 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
|
||||
# for more information on how to write migrations for GitLab.
|
||||
|
||||
class IndexRedirectRoutesPathForLike < ActiveRecord::Migration
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
# Set this constant to true if this migration requires downtime.
|
||||
DOWNTIME = false
|
||||
|
||||
INDEX_NAME = 'index_redirect_routes_on_path_text_pattern_ops'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
return unless Gitlab::Database.postgresql?
|
||||
|
||||
unless index_exists?(:redirect_routes, :path, name: INDEX_NAME)
|
||||
execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON redirect_routes (path varchar_pattern_ops);")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
return unless Gitlab::Database.postgresql?
|
||||
|
||||
if index_exists?(:redirect_routes, :path, name: INDEX_NAME)
|
||||
execute("DROP INDEX CONCURRENTLY #{INDEX_NAME};")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1049,6 +1049,7 @@ ActiveRecord::Schema.define(version: 20170504102911) do
|
|||
end
|
||||
|
||||
add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree
|
||||
add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"}
|
||||
add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree
|
||||
|
||||
create_table "releases", force: :cascade do |t|
|
||||
|
|
|
@ -11,4 +11,5 @@ task setup_postgresql: :environment do
|
|||
AddUsersLowerUsernameEmailIndexes.new.up
|
||||
AddLowerPathIndexToRoutes.new.up
|
||||
IndexRoutesPathForLike.new.up
|
||||
IndexRedirectRoutesPathForLike.new.up
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue