This is a patch for v0.32.0, which adds this change to batch up db insertions in order to fix a bug in which migrations would continuously loop when there was a large volume of data in the jobs database.
This patch also adds this change to prevent deadlocks when importing databases, which could have also manifested during migrations.