database migration and iteration helper