2018-12-23 12:14:25 +05:30
|
|
|
class AddLatestMergeRequestDiffIdToMergeRequests < ActiveRecord::Migration[4.2]
|
2018-03-17 18:26:18 +05:30
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
|
|
|
add_column :merge_requests, :latest_merge_request_diff_id, :integer
|
|
|
|
add_concurrent_index :merge_requests, :latest_merge_request_diff_id
|
|
|
|
|
|
|
|
add_concurrent_foreign_key :merge_requests, :merge_request_diffs,
|
|
|
|
column: :latest_merge_request_diff_id,
|
|
|
|
on_delete: :nullify
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_foreign_key :merge_requests, column: :latest_merge_request_diff_id
|
|
|
|
|
|
|
|
if index_exists?(:merge_requests, :latest_merge_request_diff_id)
|
|
|
|
remove_concurrent_index :merge_requests, :latest_merge_request_diff_id
|
|
|
|
end
|
|
|
|
|
|
|
|
remove_column :merge_requests, :latest_merge_request_diff_id
|
|
|
|
end
|
|
|
|
end
|