From 591f10f6bd8d92e083fbc3c691c874e62144ba25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Fri, 11 Nov 2016 14:23:08 -0300 Subject: [PATCH] Update 8.14-rc1 migrations to minimize downtime and deploy time See https://gitlab.com/gitlab-org/gitlab-ce/issues/24386 --- app/models/project.rb | 4 ++++ ...04_only_allow_merge_if_all_discussions_are_resolved.rb | 5 +---- ...61011222551_remove_inactive_jira_service_properties.rb | 0 db/schema.rb | 2 +- spec/requests/api/projects_spec.rb | 8 ++++++++ 5 files changed, 14 insertions(+), 5 deletions(-) rename db/{migrate => post_migrate}/20161011222551_remove_inactive_jira_service_properties.rb (100%) diff --git a/app/models/project.rb b/app/models/project.rb index bbe590b5a8a..94aabafce20 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1334,6 +1334,10 @@ class Project < ActiveRecord::Base end end + def only_allow_merge_if_all_discussions_are_resolved + super || false + end + private def pushes_since_gc_redis_key diff --git a/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb b/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb index fad62d716b3..4da5ec9bd28 100644 --- a/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb +++ b/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb @@ -5,10 +5,7 @@ class OnlyAllowMergeIfAllDiscussionsAreResolved < ActiveRecord::Migration disable_ddl_transaction! def up - add_column_with_default(:projects, - :only_allow_merge_if_all_discussions_are_resolved, - :boolean, - default: false) + add_column :projects, :only_allow_merge_if_all_discussions_are_resolved, :boolean end def down diff --git a/db/migrate/20161011222551_remove_inactive_jira_service_properties.rb b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb similarity index 100% rename from db/migrate/20161011222551_remove_inactive_jira_service_properties.rb rename to db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb diff --git a/db/schema.rb b/db/schema.rb index 64d744d8268..9db61635f8e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -912,7 +912,7 @@ ActiveRecord::Schema.define(version: 20161109150329) do t.boolean "has_external_wiki" t.boolean "lfs_enabled" t.text "description_html" - t.boolean "only_allow_merge_if_all_discussions_are_resolved", default: false, null: false + t.boolean "only_allow_merge_if_all_discussions_are_resolved" end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index d6e9fd2c4b2..f020d471422 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -360,6 +360,14 @@ describe API::API, api: true do expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey end + it 'sets a project as allowing merge if only_allow_merge_if_all_discussions_are_resolved is nil' do + project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: nil) + + post api('/projects', user), project + + expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey + end + it 'sets a project as allowing merge only if all discussions are resolved' do project = attributes_for(:project, { only_allow_merge_if_all_discussions_are_resolved: true })