Revert rename allow collaboration column

This commit is contained in:
Mark Chao 2018-06-08 13:12:51 +00:00 committed by Yorick Peterse
parent e1f9f3c6ac
commit 68cb1c2651
7 changed files with 56 additions and 8 deletions

View file

@ -1125,8 +1125,11 @@ class MergeRequest < ActiveRecord::Base
project.merge_requests.merged.where(author_id: author_id).empty? project.merge_requests.merged.where(author_id: author_id).empty?
end end
# TODO: remove once production database rename completes
alias_attribute :allow_collaboration, :allow_maintainer_to_push
def allow_collaboration def allow_collaboration
collaborative_push_possible? && super collaborative_push_possible? && allow_maintainer_to_push
end end
alias_method :allow_collaboration?, :allow_collaboration alias_method :allow_collaboration?, :allow_collaboration

View file

@ -6,10 +6,12 @@ class RenameMergeRequestsAllowMaintainerToPush < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
rename_column_concurrently :merge_requests, :allow_maintainer_to_push, :allow_collaboration # NOOP
end end
def down 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
end end

View file

@ -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

View file

@ -6,10 +6,12 @@ class CleanupMergeRequestsAllowMaintainerToPushRename < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
cleanup_concurrent_column_rename :merge_requests, :allow_maintainer_to_push, :allow_collaboration # NOOP
end end
def down 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
end end

View file

@ -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

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -1231,8 +1231,8 @@ ActiveRecord::Schema.define(version: 20180603190921) do
t.boolean "discussion_locked" t.boolean "discussion_locked"
t.integer "latest_merge_request_diff_id" t.integer "latest_merge_request_diff_id"
t.string "rebase_commit_sha" t.string "rebase_commit_sha"
t.boolean "allow_collaboration"
t.boolean "squash", default: false, null: false t.boolean "squash", default: false, null: false
t.boolean "allow_maintainer_to_push"
end end
add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree

View file

@ -170,7 +170,7 @@ MergeRequest:
- last_edited_by_id - last_edited_by_id
- head_pipeline_id - head_pipeline_id
- discussion_locked - discussion_locked
- allow_collaboration - allow_maintainer_to_push
MergeRequestDiff: MergeRequestDiff:
- id - id
- state - state