summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-21 14:31:49 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-21 14:31:49 +0200
commite4d42a62d928d31390ce29fc52891a8973784f2d (patch)
treee8b334555b95053680ed939c62cc57993e8aed25 /lib
parent4e8d6507bff12403d295b2d39432d50dcbeb7160 (diff)
downloadgitlab-ce-e4d42a62d928d31390ce29fc52891a8973784f2d.tar.gz
Raise if updating columns in batches within a transaction
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 9181202a091..85a8a44c8d6 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'))