summaryrefslogtreecommitdiff
path: root/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20170503185032_index_redirect_routes_path_for_like.rb')
-rw-r--r--db/migrate/20170503185032_index_redirect_routes_path_for_like.rb29
1 files changed, 29 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