Fixed #23745 -- Improved migrate speed

Of course, commit c7ea633 will not be eventually included, it only serves to measure performance.
For the sake of consistency, can we convert `model_name` to lower in here. All occurrences are calling `.lower()` explicitly.