diff --git a/changelogs/unreleased/sh-add-index-to-system-note-metadata.yml b/changelogs/unreleased/sh-add-index-to-system-note-metadata.yml
new file mode 100644
index 0000000000000000000000000000000000000000..6b226c53f3087797fe2714cffdbf5abdad080d08
--- /dev/null
+++ b/changelogs/unreleased/sh-add-index-to-system-note-metadata.yml
@@ -0,0 +1,4 @@
+---
+title: Add unique index for notes_id to system note metadata table
+merge_request:
+author:
diff --git a/db/migrate/20170419001229_add_index_to_system_note_metadata.rb b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb
new file mode 100644
index 0000000000000000000000000000000000000000..c68fd920fff45c17b30546e517b0b19e51ad5b4a
--- /dev/null
+++ b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb
@@ -0,0 +1,17 @@
+class AddIndexToSystemNoteMetadata < ActiveRecord::Migration
+  include Gitlab::Database::MigrationHelpers
+
+  # Set this constant to true if this migration requires downtime.
+  DOWNTIME = false
+
+  disable_ddl_transaction!
+
+  def up
+    # MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not
+    add_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql?
+  end
+
+  def down
+    remove_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql?
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d46b756495866d2f9b2830603b29e7e5b1e73dc4..f89e9adb7d69b5c124fae841f2723411ab028a0f 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: 20170418103908) do
+ActiveRecord::Schema.define(version: 20170419001229) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -1142,6 +1142,8 @@ ActiveRecord::Schema.define(version: 20170418103908) do
     t.datetime "updated_at", null: false
   end
 
+  add_index "system_note_metadata", ["note_id"], name: "index_system_note_metadata_on_note_id", unique: true, using: :btree
+
   create_table "taggings", force: :cascade do |t|
     t.integer "tag_id"
     t.integer "taggable_id"