diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-05-12 16:27:30 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-05-12 16:27:30 +0200 |
commit | 3fc20c01170ebb6648ff9dbe76b0d52d0c13d68d (patch) | |
tree | cf035dc7da9239d4c9e66b33dfd9fad723e1a402 /lib | |
parent | 99f36c2ca69de17235eeab53f510753b6c1ae7c4 (diff) | |
download | gitlab-ce-3fc20c01170ebb6648ff9dbe76b0d52d0c13d68d.tar.gz |
Fix adding defaults for concurrent column renamesrename-column-concurrently-defaults
By adding the default value _after_ adding the column we avoid updating
all rows in a table, saving a lot of time and unnecessary work in the
process.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index f04a907004c..f3476dadec8 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -283,11 +283,15 @@ module Gitlab 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) + # We set the default value _after_ adding the column so we don't end up + # updating any existing data with the default value. This isn't + # necessary since we copy over old values further down. + change_column_default(table, new, old_col.default) if old_col.default + trigger_name = rename_trigger_name(table, old, new) quoted_table = quote_table_name(table) quoted_old = quote_column_name(old) |