From 42e1080d54cf32919a5592bbdeef1857afc90783 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 18 Jul 2018 16:34:04 +0200 Subject: WIP parallel DB migrations --- app/models/concerns/each_batch.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models') 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' -- cgit v1.2.1