[1.7.x] Fixed #23975 -- Restored pre_migrate signal if all apps have migrations.

Thanks kmmbvnr for the report.

Backport of d2ff8a7241b621b8013c7ec1631e95ae4445f76d from master