summaryrefslogtreecommitdiff
path: root/db/migrate/20190729180447_add_merge_requests_require_code_owner_approval_to_protected_branches.rb
blob: bfac67606d6435d213734286b466a78d7c5cd84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

class AddMergeRequestsRequireCodeOwnerApprovalToProtectedBranches < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault
      :protected_branches,
      :code_owner_approval_required,
      :boolean,
      default: false
    )

    add_concurrent_index(
      :protected_branches,
      [:project_id, :code_owner_approval_required],
      name: "code_owner_approval_required",
      where: "code_owner_approval_required = #{Gitlab::Database.true_value}")
  end

  def down
    remove_concurrent_index(:protected_branches, name: "code_owner_approval_required")

    remove_column(:protected_branches, :code_owner_approval_required)
  end
end