The usual approach
A migration can be functionally perfect and still fail in production if the translated code runs significantly slower than the original. Performance regressions are one of the most common, and most dangerous, surprises after a database migration.