diff --git a/lib/safe-pg-migrations/helpers/batch_over.rb b/lib/safe-pg-migrations/helpers/batch_over.rb index d256b8ec..8d5ffb45 100644 --- a/lib/safe-pg-migrations/helpers/batch_over.rb +++ b/lib/safe-pg-migrations/helpers/batch_over.rb @@ -19,11 +19,11 @@ def each_batch def next_batch return if endless? - first = next_scope.take + first = next_scope.select(primary_key).take return unless first - last = next_scope.offset(@of).take + last = next_scope.select(primary_key).offset(@of).take first_key = first[primary_key] last_key = last.nil? ? nil : last[primary_key]