Commit beec97f6 authored by Douwe Maan's avatar Douwe Maan

Disallow NULL on renamed column after default has been set

parent 84199f19
...@@ -283,7 +283,6 @@ module Gitlab ...@@ -283,7 +283,6 @@ module Gitlab
add_column(table, new, new_type, add_column(table, new, new_type,
limit: old_col.limit, limit: old_col.limit,
null: old_col.null,
precision: old_col.precision, precision: old_col.precision,
scale: old_col.scale) scale: old_col.scale)
...@@ -307,6 +306,8 @@ module Gitlab ...@@ -307,6 +306,8 @@ module Gitlab
update_column_in_batches(table, new, Arel::Table.new(table)[old]) update_column_in_batches(table, new, Arel::Table.new(table)[old])
change_column_null(table, new, false) unless old_col.null
copy_indexes(table, old, new) copy_indexes(table, old, new)
copy_foreign_keys(table, old, new) copy_foreign_keys(table, old, new)
end end
......
...@@ -382,7 +382,6 @@ describe Gitlab::Database::MigrationHelpers, lib: true do ...@@ -382,7 +382,6 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(model).to receive(:add_column). expect(model).to receive(:add_column).
with(:users, :new, :integer, with(:users, :new, :integer,
limit: old_column.limit, limit: old_column.limit,
null: old_column.null,
precision: old_column.precision, precision: old_column.precision,
scale: old_column.scale) scale: old_column.scale)
...@@ -391,6 +390,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do ...@@ -391,6 +390,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(model).to receive(:update_column_in_batches) expect(model).to receive(:update_column_in_batches)
expect(model).to receive(:change_column_null).with(:users, :new, false)
expect(model).to receive(:copy_indexes).with(:users, :old, :new) expect(model).to receive(:copy_indexes).with(:users, :old, :new)
expect(model).to receive(:copy_foreign_keys).with(:users, :old, :new) expect(model).to receive(:copy_foreign_keys).with(:users, :old, :new)
...@@ -408,7 +409,6 @@ describe Gitlab::Database::MigrationHelpers, lib: true do ...@@ -408,7 +409,6 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(model).to receive(:add_column). expect(model).to receive(:add_column).
with(:users, :new, :integer, with(:users, :new, :integer,
limit: old_column.limit, limit: old_column.limit,
null: old_column.null,
precision: old_column.precision, precision: old_column.precision,
scale: old_column.scale) scale: old_column.scale)
...@@ -417,6 +417,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do ...@@ -417,6 +417,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(model).to receive(:update_column_in_batches) expect(model).to receive(:update_column_in_batches)
expect(model).to receive(:change_column_null).with(:users, :new, false)
expect(model).to receive(:copy_indexes).with(:users, :old, :new) expect(model).to receive(:copy_indexes).with(:users, :old, :new)
expect(model).to receive(:copy_foreign_keys).with(:users, :old, :new) expect(model).to receive(:copy_foreign_keys).with(:users, :old, :new)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment