summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-07-18 16:34:04 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2018-07-18 16:34:04 +0200
commit42e1080d54cf32919a5592bbdeef1857afc90783 (patch)
treebb312c77c341d9959b67ddf65325c60fcefc3924 /app/models
parent4736e0519b0d8c66ab35fd636f5f81089822ba7a (diff)
downloadgitlab-ce-parallel-db-migrations.tar.gz
WIP parallel DB migrationsparallel-db-migrations
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/each_batch.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/concerns/each_batch.rb b/app/models/concerns/each_batch.rb
index 6ddbb8da1a9..6baa9edc263 100644
--- a/app/models/concerns/each_batch.rb
+++ b/app/models/concerns/each_batch.rb
@@ -38,6 +38,10 @@ module EachBatch
# of - The number of rows to retrieve per batch.
# column - The column to use for ordering the batches.
def each_batch(of: 1000, column: primary_key)
+ unless block_given?
+ return to_enum(__method__, of: of, column: column).lazy
+ end
+
unless column
raise ArgumentError,
'the column: argument must be set to a column name to use for ordering rows'