Commit ccfe6860 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'add-composite-index-on-merge-requests-merge-commit-sha' into 'master'

Add index for merge_requests.merge_commit_sha

Closes #38507

See merge request gitlab-org/gitlab-ce!14549
parents 8a7ca539 abcfdd5c
---
title: Add index for merge_requests.merge_commit_sha
merge_request:
author:
type: other
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddCompositeIndexOnMergeRequestsMergeCommitSha < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# The default index name is too long for PostgreSQL and would thus be
# truncated.
INDEX_NAME = 'index_merge_requests_on_tp_id_and_merge_commit_sha_and_id'
COLUMNS = [:target_project_id, :merge_commit_sha, :id]
disable_ddl_transaction!
def up
return if index_is_present?
add_concurrent_index(:merge_requests, COLUMNS, name: INDEX_NAME)
end
def down
return unless index_is_present?
remove_concurrent_index(:merge_requests, COLUMNS, name: INDEX_NAME)
end
def index_is_present?
index_exists?(:merge_requests, COLUMNS, name: INDEX_NAME)
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170921115009) do ActiveRecord::Schema.define(version: 20170928100231) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -895,6 +895,7 @@ ActiveRecord::Schema.define(version: 20170921115009) do ...@@ -895,6 +895,7 @@ ActiveRecord::Schema.define(version: 20170921115009) do
add_index "merge_requests", ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_id_and_source_branch", using: :btree add_index "merge_requests", ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_id_and_source_branch", using: :btree
add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree
add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree
add_index "merge_requests", ["target_project_id", "merge_commit_sha", "id"], name: "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id", using: :btree
add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree
add_index "merge_requests", ["title"], name: "index_merge_requests_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} add_index "merge_requests", ["title"], name: "index_merge_requests_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment