pg_restore: error: could not execute query: ERROR: type "test_type" does not exist LINE 1: SELECT array_agg((e->>'item')::test_type) FROM jsonb_array_...
This is an application bug, not Postgres. You relied on the public schema being in search_path but didn't declare that fact via SET on the function. Either use SET, or schema-qualify objects so you don't have to rely on search_path at all.