PostgreSQL – Handling Unknown Column Types During Migration

migrationpostgresql

I am trying to port a database where there is a table with a column of type unknown. pg_restore raised the error

pg_restore: [archiver (db)] could not execute query: ERROR: column "color" has pseudo-type unknown`.

I don't understand why such tables can exist given that the doc says

A pseudo-type cannot be used as a column data type

However, I want to keep the database as it is and do not do any modifications. Which error code should I specify to catch this exception?

Best Answer

This must be a dump from an old PostgreSQL database where it was still possible to generate unknown columns.

The best thing would be to fix the source database, but if you cannot do that, generate an SQL script from the dump with pg_restore and fix the column definitions there.