next_migration_number refactoring