diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-05-11 15:50:46 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-05-11 15:50:46 +0000 |
commit | 466564d9a3e2661e257c424c8862fa00fe07e61f (patch) | |
tree | e7fd8d23eace4a555aafd0ddfdc9e540c852ff72 | |
parent | b2e5d40ab81d9605fdbae4339cd8a0b6cc490524 (diff) | |
parent | 49fb31db416cb73899cf5211de8f5817c00adc0b (diff) | |
download | gitlab-ce-466564d9a3e2661e257c424c8862fa00fe07e61f.tar.gz |
Merge branch 'bvl-mysql-rename-concurrently' into 'master'
Add a new column before creating rename triggers
See merge request !11297
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 298b1a1f4e6..f04a907004c 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -278,6 +278,16 @@ module Gitlab raise 'rename_column_concurrently can not be run inside a transaction' end + old_col = column_for(table, old) + new_type = type || old_col.type + + add_column(table, new, new_type, + limit: old_col.limit, + default: old_col.default, + null: old_col.null, + precision: old_col.precision, + scale: old_col.scale) + trigger_name = rename_trigger_name(table, old, new) quoted_table = quote_table_name(table) quoted_old = quote_column_name(old) @@ -291,16 +301,6 @@ module Gitlab quoted_old, quoted_new) end - old_col = column_for(table, old) - new_type = type || old_col.type - - add_column(table, new, new_type, - limit: old_col.limit, - default: old_col.default, - null: old_col.null, - precision: old_col.precision, - scale: old_col.scale) - update_column_in_batches(table, new, Arel::Table.new(table)[old]) copy_indexes(table, old, new) |