Write and implement swap_foreign_key_for_output