diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-13 12:22:58 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-13 12:22:58 +0300 |
commit | b33b7be53e113e4f07154b6aafb7858d76d99516 (patch) | |
tree | 28c672476c27ec57184eff6246fb160c94924801 /spec/lib | |
parent | 65df6bcb898e067e380658431136b5ef9aaba3b0 (diff) |
Handle NULL migration errors in migration helpers
This ensures that whenever changing the NULL constraint of a column
fails we still drop the column.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/database/migration_helpers_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 83ddabe6b0b..1ec539066a7 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -120,6 +120,19 @@ describe Gitlab::Database::MigrationHelpers, lib: true do model.add_column_with_default(:projects, :foo, :integer, default: 10) end.to raise_error(RuntimeError) end + + it 'removes the added column whenever changing a column NULL constraint fails' do + expect(model).to receive(:change_column_null). + with(:projects, :foo, false). + and_raise(RuntimeError) + + expect(model).to receive(:remove_column). + with(:projects, :foo) + + expect do + model.add_column_with_default(:projects, :foo, :integer, default: 10) + end.to raise_error(RuntimeError) + end end context 'inside a transaction' do |