summaryrefslogtreecommitdiff
path: root/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
blob: 8cf636e1da6495d05dea396ee262ed87f5218cd4 (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
class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  # rubocop:disable Migration/Datetime
  # rubocop:disable Migration/PreventStrings
  def up
    add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at)
    add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name)

    unless column_exists?(:remote_mirrors, :only_protected_branches)
      add_column_with_default(:remote_mirrors, # rubocop:disable Migration/AddColumnWithDefault
                              :only_protected_branches,
                              :boolean,
                              default: false,
                              allow_null: false)
    end
  end
  # rubocop:enable Migration/PreventStrings
  # rubocop:enable Migration/Datetime

  def down
    # db/migrate/20180503131624_create_remote_mirrors.rb will remove the table
  end
end