summaryrefslogtreecommitdiff
path: root/db/migrate/20170503184421_add_index_to_redirect_routes.rb
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-05-03 11:49:17 -0700
committerMichael Kozono <mkozono@gmail.com>2017-05-05 12:12:24 -0700
commit4da848ef28fb9ff247145670a107dff82c83b270 (patch)
tree4c3806ba6f11fd5dd10d9dca607ea2c63308ed36 /db/migrate/20170503184421_add_index_to_redirect_routes.rb
parente8f2a7007a96d19cf7f7e7278bf21007fafa9f1c (diff)
downloadgitlab-ce-4da848ef28fb9ff247145670a107dff82c83b270.tar.gz
Add index for source association and for path
Diffstat (limited to 'db/migrate/20170503184421_add_index_to_redirect_routes.rb')
-rw-r--r--db/migrate/20170503184421_add_index_to_redirect_routes.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20170503184421_add_index_to_redirect_routes.rb b/db/migrate/20170503184421_add_index_to_redirect_routes.rb
new file mode 100644
index 00000000000..5991f6ab6a1
--- /dev/null
+++ b/db/migrate/20170503184421_add_index_to_redirect_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.
+
+# rubocop:disable RemoveIndex
+class AddIndexToRedirectRoutes < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:redirect_routes, :path, unique: true)
+ add_concurrent_index(:redirect_routes, [:source_type, :source_id])
+ end
+
+ def down
+ remove_index(:redirect_routes, :path) if index_exists?(:redirect_routes, :path)
+ remove_index(:redirect_routes, [:source_type, :source_id]) if index_exists?(:redirect_routes, [:source_type, :source_id])
+ end
+end