From ad4b6302d4dc13eb8a742b9e1c742d40d8cf6ec8 Mon Sep 17 00:00:00 2001
From: James Lopez <james@gitlab.com>
Date: Tue, 25 Apr 2017 15:21:18 +0000
Subject: [PATCH] Add index to webhooks type column

---
 changelogs/unreleased/fix-web_hooks-index.yml     |  4 ++++
 .../20170424142900_add_index_to_web_hooks_type.rb | 15 +++++++++++++++
 db/schema.rb                                      |  3 ++-
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 changelogs/unreleased/fix-web_hooks-index.yml
 create mode 100644 db/migrate/20170424142900_add_index_to_web_hooks_type.rb

diff --git a/changelogs/unreleased/fix-web_hooks-index.yml b/changelogs/unreleased/fix-web_hooks-index.yml
new file mode 100644
index 00000000000..16f233e2e7c
--- /dev/null
+++ b/changelogs/unreleased/fix-web_hooks-index.yml
@@ -0,0 +1,4 @@
+---
+title: Add index to webhooks type column
+merge_request:
+author:
diff --git a/db/migrate/20170424142900_add_index_to_web_hooks_type.rb b/db/migrate/20170424142900_add_index_to_web_hooks_type.rb
new file mode 100644
index 00000000000..9af158e3844
--- /dev/null
+++ b/db/migrate/20170424142900_add_index_to_web_hooks_type.rb
@@ -0,0 +1,15 @@
+class AddIndexToWebHooksType < ActiveRecord::Migration
+  include Gitlab::Database::MigrationHelpers
+
+  DOWNTIME = false
+
+  disable_ddl_transaction!
+
+  def up
+    add_concurrent_index :web_hooks, :type
+  end
+
+  def down
+    remove_concurrent_index :web_hooks, :type
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7b13f2a98a1..bd6fef22d06 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: 20170423064036) do
+ActiveRecord::Schema.define(version: 20170424142900) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -1371,6 +1371,7 @@ ActiveRecord::Schema.define(version: 20170423064036) do
   end
 
   add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree
+  add_index "web_hooks", ["type"], name: "index_web_hooks_on_type", using: :btree
 
   add_foreign_key "boards", "projects"
   add_foreign_key "chat_teams", "namespaces", on_delete: :cascade
-- 
GitLab