Use migration helper to prevent downtime migration

This commit is contained in:
Grzegorz Bizon 2016-05-19 22:11:40 +02:00
parent 4cc77c3bf8
commit 52c8b9da37
1 changed files with 10 additions and 8 deletions

View File

@ -1,11 +1,13 @@
class AddRunUntaggedToCiRunner < ActiveRecord::Migration
##
# Downtime expected!
#
# This migration will cause downtime due to exclusive lock
# caused by the default value.
#
def change
add_column :ci_runners, :run_untagged, :boolean, default: true, null: false
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
add_column_with_default(:ci_runners, :run_untagged, :boolean,
default: true, allow_null: false)
end
def down
remove_column(:ci_runners, :run_untagged)
end
end