summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-06-23 15:30:29 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-06-23 15:30:29 +0000
commita4c81b6416b3b6cb852de2716240accf0d7f99eb (patch)
treea18ff50b09baf145939e181b0b2d242c5a6d5f43 /lib
parent523eaace0211f134bf24286ededa3f09b05b1d5f (diff)
parent019b4d34651d0638567ddd337c0cf74ba9ddeced (diff)
downloadgitlab-ce-a4c81b6416b3b6cb852de2716240accf0d7f99eb.tar.gz
Merge branch 'fix/gb/improve-updating-column-in-batches-helper' into 'master'
Improve `update_column_in_batches` migration helper Closes #34064 See merge request !12350
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database/migration_helpers.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index 60cce9c6d9e..0643c56db9b 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -222,6 +222,12 @@ module Gitlab
#
# rubocop: disable Metrics/AbcSize
def update_column_in_batches(table, column, value)
+ if transaction_open?
+ raise 'update_column_in_batches can not be run inside a transaction, ' \
+ 'you can disable transactions by calling disable_ddl_transaction! ' \
+ 'in the body of your migration class'
+ end
+
table = Arel::Table.new(table)
count_arel = table.project(Arel.star.count.as('count'))