Merge branch 'fix-mr-cleanup' into 'master'
Fix merge_requests.source_project_id migration See merge request gitlab-org/gitlab-ce!15496
This commit is contained in:
commit
31ba9870ce
|
@ -21,15 +21,15 @@ class MergeRequestsSourceProjectIdForeignKey < ActiveRecord::Migration
|
||||||
end
|
end
|
||||||
|
|
||||||
def up
|
def up
|
||||||
MergeRequest.with_orphaned_source_projects.each_batch(of: 100) do |batch|
|
|
||||||
batch.update_all(source_project_id: nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
# We need to allow NULL values so we can nullify the column when the source
|
# We need to allow NULL values so we can nullify the column when the source
|
||||||
# project is removed. We _don't_ want to remove the merge request, instead
|
# project is removed. We _don't_ want to remove the merge request, instead
|
||||||
# the application will keep them but close them.
|
# the application will keep them but close them.
|
||||||
change_column_null(:merge_requests, :source_project_id, true)
|
change_column_null(:merge_requests, :source_project_id, true)
|
||||||
|
|
||||||
|
MergeRequest.with_orphaned_source_projects.each_batch(of: 100) do |batch|
|
||||||
|
batch.update_all(source_project_id: nil)
|
||||||
|
end
|
||||||
|
|
||||||
add_concurrent_foreign_key(
|
add_concurrent_foreign_key(
|
||||||
:merge_requests,
|
:merge_requests,
|
||||||
:projects,
|
:projects,
|
||||||
|
|
Loading…
Reference in New Issue