Agrego aquí la solución completa para crear tipos en un script simple, sin necesidad de crear una función solo para este propósito.
--create types
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'my_type') THEN
CREATE TYPE my_type AS
(
--my fields here...
);
END IF;
--more types here...
END$$;