Fix the index for finished at

This commit is contained in:
Shinya Maeda 2018-11-06 22:34:29 +09:00
parent 065af93d6b
commit 12a73596cc
2 changed files with 4 additions and 2 deletions

View File

@ -4,6 +4,7 @@ class AddIndexToDeployments < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
SHORT_INDEX_NAME = 'index_deployments_on_deployed_for_finished_at'
disable_ddl_transaction!
@ -11,13 +12,13 @@ class AddIndexToDeployments < ActiveRecord::Migration
add_concurrent_index :deployments, [:project_id, :action, :status]
add_concurrent_index :deployments, [:environment_id, :action, :status]
add_concurrent_index :deployments, [:environment_id, :action, :sha]
add_concurrent_index :deployments, [:finished_at]
add_concurrent_index :deployments, [:project_id, :action, :status, :finished_at], name: SHORT_INDEX_NAME
end
def down
remove_concurrent_index :deployments, [:project_id, :action, :status]
remove_concurrent_index :deployments, [:environment_id, :action, :status]
remove_concurrent_index :deployments, [:environment_id, :action, :sha]
remove_concurrent_index :deployments, [:finished_at]
remove_concurrent_index_by_name(:deployments, SHORT_INDEX_NAME)
end
end

View File

@ -839,6 +839,7 @@ ActiveRecord::Schema.define(version: 20181106135939) do
add_index "deployments", ["environment_id", "status"], name: "index_deployments_on_environment_id_and_status", using: :btree
add_index "deployments", ["finished_at"], name: "index_deployments_on_finished_at", using: :btree
add_index "deployments", ["id"], name: "partial_index_deployments_for_legacy_successful_deployments", where: "((finished_at IS NULL) AND (status = 2))", using: :btree
add_index "deployments", ["project_id", "action", "status", "finished_at"], name: "index_deployments_on_deployed_for_finished_at", using: :btree
add_index "deployments", ["project_id", "action", "status"], name: "index_deployments_on_project_id_and_action_and_status", using: :btree
add_index "deployments", ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true, using: :btree
add_index "deployments", ["project_id", "status"], name: "index_deployments_on_project_id_and_status", using: :btree