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:
authorGreg Stark <stark@gitlab.com>2017-12-20 22:43:41 +0300
committerGreg Stark <stark@gitlab.com>2017-12-22 02:07:25 +0300
commit680ebf449bc5700f827559660f28fb4e47022828 (patch)
tree40d399c11c7a2a8be65fe87d7954f7bee1997906 /db
parent82e31ee46784cc4a0b987511ce7506dd01a3f004 (diff)
Add index on namespaces lower(name) for UsersController#exists
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb30
-rw-r--r--db/schema.rb2
2 files changed, 31 insertions, 1 deletions
diff --git a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
new file mode 100644
index 00000000000..7cf1d0cec68
--- /dev/null
+++ b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
@@ -0,0 +1,30 @@
+class AddIndexOnNamespacesLowerName < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+ INDEX_NAME = 'index_on_namespaces_lower_name'
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab::Database.postgresql?
+
+ disable_statement_timeout
+ if Gitlab::Database.version.to_f >= 9.5
+ # Allow us to hot-patch the index manually ahead of the migration
+ execute "CREATE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME} ON namespaces (lower(name));"
+ else
+ execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON namespaces (lower(name));"
+ end
+ end
+
+ def down
+ return unless Gitlab::Database.postgresql?
+
+ disable_statement_timeout
+ if Gitlab::Database.version.to_f >= 9.2
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME};"
+ else
+ execute "DROP INDEX IF EXISTS #{INDEX_NAME};"
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2b20628bd53..81b594cd0c1 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: 20171219121201) do
+ActiveRecord::Schema.define(version: 20171220191323) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"