summaryrefslogtreecommitdiff
path: root/db
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
parente8f2a7007a96d19cf7f7e7278bf21007fafa9f1c (diff)
downloadgitlab-ce-4da848ef28fb9ff247145670a107dff82c83b270.tar.gz
Add index for source association and for path
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170503184421_add_index_to_redirect_routes.rb22
-rw-r--r--db/schema.rb5
2 files changed, 26 insertions, 1 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
diff --git a/db/schema.rb b/db/schema.rb
index 3a8970b2235..45c3b9a4c91 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1048,6 +1048,9 @@ ActiveRecord::Schema.define(version: 20170504102911) do
t.datetime "updated_at", null: false
end
+ add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree
+ add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree
+
create_table "releases", force: :cascade do |t|
t.string "tag"
t.text "description"
@@ -1423,4 +1426,4 @@ ActiveRecord::Schema.define(version: 20170504102911) do
add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade
add_foreign_key "trending_projects", "projects", on_delete: :cascade
add_foreign_key "u2f_registrations", "users"
-end \ No newline at end of file
+end