Fix for foreign key schema migration

See b7c6390659 for details.