nextBatchNumber method

  1. @override
Future<int> nextBatchNumber()
override

Determines the next batch number to use when logging migrations.

Implementation

@override
Future<int> nextBatchNumber() => _withDriver((driver) async {
  final context = _contextForDriver(driver);

  // Find the max batch number by processing records in chunks
  var maxBatch = 0;
  await context.query<$OrmMigrationRecord>().chunk(50, (rows) {
    for (final row in rows) {
      if (row.model.batch > maxBatch) {
        maxBatch = row.model.batch;
      }
    }
    return true; // Continue processing
  });

  return maxBatch + 1;
});