Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20170317203554_index_routes_path_for_like.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7ac09b2abe5bed30b1f6b8c9c6605f0553a1f949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class IndexRoutesPathForLike < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  INDEX_NAME = 'index_routes_on_path_text_pattern_ops'

  disable_ddl_transaction!

  def up
    return unless Gitlab::Database.postgresql?

    unless index_exists?(:routes, :path, name: INDEX_NAME)
      execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON routes (path varchar_pattern_ops);")
    end
  end

  def down
    return unless Gitlab::Database.postgresql?

    if index_exists?(:routes, :path, name: INDEX_NAME)
      execute("DROP INDEX CONCURRENTLY #{INDEX_NAME};")
    end
  end
end