Thanks to Markus, Marten and Sergei for help and review.
Backport of b7ea494d65e4d9703a0a24f0cd708293df88f48b and
c643b4c9f2acfdcb562bdbec1d74ac797b890b9b from master
The new signature enables better support for routing RunPython and
RunSQL operations, especially w.r.t. reusable and third-party apps.
This commit also takes advantage of the deprecation cycle for the old
signature to remove the backward incompatibility introduced in #22583;
RunPython and RunSQL won't call allow_migrate() when when the router
has the old signature.
Thanks Aymeric Augustin and Tim Graham for helping shape up the patch.
Refs 22583.