blob: 450b276e6891c9ebf27fe5ea9056a0b37e995862 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# frozen_string_literal: true
class ChangeUpdatedAtIndexAndAddIndexToIdOnDeployments < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
PROJECT_ID_INDEX_PARAMS = [[:project_id, :id], order: { id: :desc }]
OLD_UPDATED_AT_INDEX_PARAMS = [[:project_id, :updated_at]]
NEW_UPDATED_AT_INDEX_PARAMS = [[:project_id, :updated_at, :id], order: { updated_at: :desc, id: :desc }]
def up
add_concurrent_index :deployments, *NEW_UPDATED_AT_INDEX_PARAMS
remove_concurrent_index :deployments, *OLD_UPDATED_AT_INDEX_PARAMS
add_concurrent_index :deployments, *PROJECT_ID_INDEX_PARAMS
end
def down
add_concurrent_index :deployments, *OLD_UPDATED_AT_INDEX_PARAMS
remove_concurrent_index :deployments, *NEW_UPDATED_AT_INDEX_PARAMS
remove_concurrent_index :deployments, *PROJECT_ID_INDEX_PARAMS
end
end
|