diff options
7 files changed, 56 insertions, 8 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 535a2c362f2..324065c1162 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1125,8 +1125,11 @@ class MergeRequest < ActiveRecord::Base project.merge_requests.merged.where(author_id: author_id).empty? end + # TODO: remove once production database rename completes + alias_attribute :allow_collaboration, :allow_maintainer_to_push + def allow_collaboration - collaborative_push_possible? && super + collaborative_push_possible? && allow_maintainer_to_push end alias_method :allow_collaboration?, :allow_collaboration diff --git a/db/migrate/20180523042841_rename_merge_requests_allow_maintainer_to_push.rb b/db/migrate/20180523042841_rename_merge_requests_allow_maintainer_to_push.rb index 975bdfe70f4..41bc7b71694 100644 --- a/db/migrate/20180523042841_rename_merge_requests_allow_maintainer_to_push.rb +++ b/db/migrate/20180523042841_rename_merge_requests_allow_maintainer_to_push.rb @@ -6,10 +6,12 @@ class RenameMergeRequestsAllowMaintainerToPush < ActiveRecord::Migration disable_ddl_transaction! def up - rename_column_concurrently :merge_requests, :allow_maintainer_to_push, :allow_collaboration + # NOOP end def down - cleanup_concurrent_column_rename :merge_requests, :allow_collaboration, :allow_maintainer_to_push + if column_exists?(:merge_requests, :allow_collaboration) + cleanup_concurrent_column_rename :merge_requests, :allow_collaboration, :allow_maintainer_to_push + end end end diff --git a/db/migrate/20180608110058_rename_merge_requests_allow_collaboration.rb b/db/migrate/20180608110058_rename_merge_requests_allow_collaboration.rb new file mode 100644 index 00000000000..dcbbef9bd4a --- /dev/null +++ b/db/migrate/20180608110058_rename_merge_requests_allow_collaboration.rb @@ -0,0 +1,21 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RenameMergeRequestsAllowCollaboration < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + if column_exists?(:merge_requests, :allow_collaboration) + rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push + end + end + + def down + # NOOP + end +end diff --git a/db/post_migrate/20180523125103_cleanup_merge_requests_allow_maintainer_to_push_rename.rb b/db/post_migrate/20180523125103_cleanup_merge_requests_allow_maintainer_to_push_rename.rb index b9ce4600675..7301bcf2c6c 100644 --- a/db/post_migrate/20180523125103_cleanup_merge_requests_allow_maintainer_to_push_rename.rb +++ b/db/post_migrate/20180523125103_cleanup_merge_requests_allow_maintainer_to_push_rename.rb @@ -6,10 +6,12 @@ class CleanupMergeRequestsAllowMaintainerToPushRename < ActiveRecord::Migration disable_ddl_transaction! def up - cleanup_concurrent_column_rename :merge_requests, :allow_maintainer_to_push, :allow_collaboration + # NOOP end def down - rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push + if column_exists?(:merge_requests, :allow_collaboration) + rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push + end end end diff --git a/db/post_migrate/20180608201435_cleanup_merge_requests_allow_collaboration_rename.rb b/db/post_migrate/20180608201435_cleanup_merge_requests_allow_collaboration_rename.rb new file mode 100644 index 00000000000..3f3edb8ea3d --- /dev/null +++ b/db/post_migrate/20180608201435_cleanup_merge_requests_allow_collaboration_rename.rb @@ -0,0 +1,20 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CleanupMergeRequestsAllowCollaborationRename < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + if column_exists?(:merge_requests, :allow_collaboration) + cleanup_concurrent_column_rename :merge_requests, :allow_collaboration, :allow_maintainer_to_push + end + end + + def down + # NOOP + end +end diff --git a/db/schema.rb b/db/schema.rb index d1446af0a2e..d05c6afbb9f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180603190921) do +ActiveRecord::Schema.define(version: 20180608201435) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1231,8 +1231,8 @@ ActiveRecord::Schema.define(version: 20180603190921) do t.boolean "discussion_locked" t.integer "latest_merge_request_diff_id" t.string "rebase_commit_sha" - t.boolean "allow_collaboration" t.boolean "squash", default: false, null: false + t.boolean "allow_maintainer_to_push" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 4354dca25ea..0a1e3eb83d3 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -170,7 +170,7 @@ MergeRequest: - last_edited_by_id - head_pipeline_id - discussion_locked -- allow_collaboration +- allow_maintainer_to_push MergeRequestDiff: - id - state |