Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-11-20 20:00:47 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-20 20:00:47 +0300
commit17132b99aaae9a398a7ae11e95b08fa0eedea0b1 (patch)
tree9e0e88b19e64826f582f8d3d741641603933c459 /db
parent7a61a8e09bcab5e0cb37ddb13900a5c07ef18918 (diff)
Fix merge_requests.source_project_id migration
We need to make sure merge_requests.source_project_id allows NULL values _before_ updating rows as otherwise this will lead to a NOT NULL constraint failing.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb
index 2965e580c84..99740f64fe6 100644
--- a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb
+++ b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb
@@ -21,15 +21,15 @@ class MergeRequestsSourceProjectIdForeignKey < ActiveRecord::Migration
end
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
# project is removed. We _don't_ want to remove the merge request, instead
# the application will keep them but close them.
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(
:merge_requests,
:projects,