summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-05-15 22:06:52 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-05-15 22:06:52 +0000
commitc53d06c4d862b2c9744894dce5776c2844fd7949 (patch)
treea6a452e70b9b12e3f92bdcb04c6937ce943b5516
parent45c19a9802e7d960283be22a626dfe128e49e03d (diff)
parentbeec97f6cf5f7357238e6f27e48115d6960f3de4 (diff)
downloadgitlab-ce-c53d06c4d862b2c9744894dce5776c2844fd7949.tar.gz
Merge branch 'dm-rename-column-concurrently-with-null' into 'master'
Disallow NULL on renamed column after default has been set See merge request !11396
-rw-r--r--lib/gitlab/database/migration_helpers.rb3
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb6
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index f3476dadec8..e76c9abbe04 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -283,7 +283,6 @@ module Gitlab
add_column(table, new, new_type,
limit: old_col.limit,
- null: old_col.null,
precision: old_col.precision,
scale: old_col.scale)
@@ -307,6 +306,8 @@ module Gitlab
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_foreign_keys(table, old, new)
end
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index d6535f97665..dfa3ae9142e 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -382,7 +382,6 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(model).to receive(:add_column).
with(:users, :new, :integer,
limit: old_column.limit,
- null: old_column.null,
precision: old_column.precision,
scale: old_column.scale)
@@ -391,6 +390,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
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_foreign_keys).with(:users, :old, :new)
@@ -408,7 +409,6 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(model).to receive(:add_column).
with(:users, :new, :integer,
limit: old_column.limit,
- null: old_column.null,
precision: old_column.precision,
scale: old_column.scale)
@@ -417,6 +417,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
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_foreign_keys).with(:users, :old, :new)