Make `.next_migration_number` reusable for third party AR generators.
Merge pull request #12407 from senny/extract_next_migration_number_into_module

Extract `.next_migration_number` into module for third party generators.