2016-06-09 12:39:16 +00:00
|
|
|
# rubocop:disable all
|
2016-04-12 17:57:54 +00:00
|
|
|
class AddCiCommitIndexes < ActiveRecord::Migration
|
2016-04-13 13:40:26 +00:00
|
|
|
disable_ddl_transaction!
|
|
|
|
|
2016-04-12 17:57:54 +00:00
|
|
|
def change
|
2016-04-13 13:40:26 +00:00
|
|
|
add_index :ci_commits, [:gl_project_id, :sha], index_options
|
|
|
|
add_index :ci_commits, [:gl_project_id, :status], index_options
|
|
|
|
add_index :ci_commits, [:status], index_options
|
|
|
|
end
|
|
|
|
|
2016-04-13 13:46:35 +00:00
|
|
|
private
|
|
|
|
|
2016-04-13 13:40:26 +00:00
|
|
|
def index_options
|
2016-04-13 14:14:27 +00:00
|
|
|
if Gitlab::Database.postgresql?
|
|
|
|
{ algorithm: :concurrently }
|
|
|
|
else
|
|
|
|
{ }
|
|
|
|
end
|
2016-04-12 17:57:54 +00:00
|
|
|
end
|
|
|
|
end
|