[Finish #52617641] Fix ensuring the index on foreign database connections