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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-07 04:01:03 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-03-28 15:12:08 +0300
commitdb75057c72e5b3c171fce898bbdeb57bff5a77b7 (patch)
tree5b427ea2936241cf797af4100f18d8efd783b3ac /db
parentf2b20e0531308d9fad90df1ed6c4af91a46327cf (diff)
Add the RedirectRoute#path index setup_postgresql
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
index 9ea4d11bb20..d6fb4f06695 100644
--- a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
+++ b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
@@ -22,17 +22,17 @@ class AddPathIndexToRedirectRoutes < ActiveRecord::Migration
disable_statement_timeout
- if_not_exists = Gitlab::Database.version.to_f >= 9.5 ? "IF NOT EXISTS" : ""
-
- # Unique index on lower(path) across both types of redirect_routes:
- execute("CREATE UNIQUE INDEX CONCURRENTLY #{if_not_exists} #{INDEX_NAME} ON redirect_routes (lower(path) varchar_pattern_ops);")
+ unless index_exists_by_name?(:redirect_routes, INDEX_NAME)
+ execute("CREATE UNIQUE INDEX CONCURRENTLY #{INDEX_NAME} ON redirect_routes (lower(path) varchar_pattern_ops);")
+ end
end
def down
- return unless Gitlab::Database.postgresql?
-
- disable_statement_timeout
-
- execute("DROP INDEX IF EXISTS #{INDEX_NAME};")
+ # Do nothing in the DOWN. Since the index above is originally created in the
+ # `ReworkRedirectRoutesIndexes`. This migration wouldn't have actually
+ # created any new index.
+ #
+ # This migration is only here to be called form `setup_postgresql.rake` so
+ # any newly created database would have this index.
end
end