summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-05-03 12:00:52 -0700
committerMichael Kozono <mkozono@gmail.com>2017-05-05 12:12:48 -0700
commit03144e1c0f2ba41a7570850b69d5029bc2619fd2 (patch)
treed25fb8c0306b1a5c4a62ecdf94d1b4aefc15dbbe /db
parent4da848ef28fb9ff247145670a107dff82c83b270 (diff)
downloadgitlab-ce-03144e1c0f2ba41a7570850b69d5029bc2619fd2.tar.gz
Index redirect_routes path for LIKE
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170503185032_index_redirect_routes_path_for_like.rb29
-rw-r--r--db/schema.rb1
2 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb
new file mode 100644
index 00000000000..5b8b6c828be
--- /dev/null
+++ b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb
@@ -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
diff --git a/db/schema.rb b/db/schema.rb
index 45c3b9a4c91..8d3f4b4bd36 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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|