diff options
author | James Lopez <james@jameslopez.es> | 2016-06-16 12:59:07 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-16 12:59:07 +0200 |
commit | 452c076a34cc11cc97f4b1c3113e86ce4367e055 (patch) | |
tree | a503b33dc6dd181e2cf56d5965fc1eb822b4d9f9 /lib/gitlab/database/migration_helpers.rb | |
parent | 13e37a3ee5c943525a99481b855d654e97e8597c (diff) | |
download | gitlab-ce-452c076a34cc11cc97f4b1c3113e86ce4367e055.tar.gz |
Revert "squashed merge and fixed conflicts"
This reverts commit 13e37a3ee5c943525a99481b855d654e97e8597c.
Diffstat (limited to 'lib/gitlab/database/migration_helpers.rb')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index dd3ff0ab18b..978c3f7896d 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -31,6 +31,8 @@ module Gitlab # Any data inserted while running this method (or after it has finished # running) is _not_ updated automatically. # + # This method _only_ updates rows where the column's value is set to NULL. + # # table - The name of the table. # column - The name of the column to update. # value - The value for the column. @@ -53,10 +55,10 @@ module Gitlab first['count']. to_i - # Update in batches of 5% until we run out of any rows to update. + # Update in batches of 5% batch_size = ((total / 100.0) * 5.0).ceil - loop do + while processed < total start_row = exec_query(%Q{ SELECT id FROM #{quoted_table} @@ -64,9 +66,6 @@ module Gitlab LIMIT 1 OFFSET #{processed} }).to_hash.first - # There are no more rows to process - break unless start_row - stop_row = exec_query(%Q{ SELECT id FROM #{quoted_table} @@ -127,8 +126,6 @@ module Gitlab begin transaction do update_column_in_batches(table, column, default) - - change_column_null(table, column, false) unless allow_null end # We want to rescue _all_ exceptions here, even those that don't inherit # from StandardError. @@ -137,6 +134,8 @@ module Gitlab raise error end + + change_column_null(table, column, false) unless allow_null end end end |