Commit 466564d9 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'bvl-mysql-rename-concurrently' into 'master'

Add a new column before creating rename triggers

See merge request !11297
parents b2e5d40a 49fb31db
...@@ -278,6 +278,16 @@ module Gitlab ...@@ -278,6 +278,16 @@ module Gitlab
raise 'rename_column_concurrently can not be run inside a transaction' raise 'rename_column_concurrently can not be run inside a transaction'
end 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) trigger_name = rename_trigger_name(table, old, new)
quoted_table = quote_table_name(table) quoted_table = quote_table_name(table)
quoted_old = quote_column_name(old) quoted_old = quote_column_name(old)
...@@ -291,16 +301,6 @@ module Gitlab ...@@ -291,16 +301,6 @@ module Gitlab
quoted_old, quoted_new) quoted_old, quoted_new)
end 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]) update_column_in_batches(table, new, Arel::Table.new(table)[old])
copy_indexes(table, old, new) copy_indexes(table, 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