From 211f019382c5e3fcf4812199aaf09b850eab09dd Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 12 Dec 2016 16:30:24 +0200 Subject: [PATCH] Add index to routes table on lower path for postgresql Signed-off-by: Dmitriy Zaporozhets --- ...12142807_add_lower_path_index_to_routes.rb | 22 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20161212142807_add_lower_path_index_to_routes.rb diff --git a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb new file mode 100644 index 00000000000..6958500306f --- /dev/null +++ b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb @@ -0,0 +1,22 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddLowerPathIndexToRoutes < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + return unless Gitlab::Database.postgresql? + + execute 'CREATE INDEX CONCURRENTLY index_on_routes_lower_path ON routes (LOWER(path));' + end + + def down + return unless Gitlab::Database.postgresql? + + remove_index :routes, name: :index_on_routes_lower_path + end +end diff --git a/db/schema.rb b/db/schema.rb index 9c46f573719..ae47456084f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161202152035) do +ActiveRecord::Schema.define(version: 20161212142807) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"