foreign_key_exists? can throw errors if run in a migration before postgres_foreign_keys has the correct columns

The foreign_key_exists? function changed in 20c4ef66 to support multiple foreign keys, and now depends on a database migration.

There is code in that function to try to revert to the previous behavior if the view does not exist in the current migration, but it seems to not work all of the time, leading to pipeline failures and failures for self-managed installations like https://gitlab.com/gitlab-org/gitlab/-/jobs/3878366136#L5406