I'm trying to gather some experience with ETL processes and for this reason I'm looking for ways to transfer data from one place to the other. Right now, I want to get a better hang of the postgres_fdw extension, because, if I understood it correctly, it allows me to import a whole schema with a single command.
IMPORT FOREIGN SCHEMA "public"
FROM SERVER dvdrental into "public";
I already followed the whole documentation with installing and using the fwd extension and manual import from other tables worked fine. However, when I try this "bulk import", for one particular table I get the following error:
ERROR: type "public.year" does not exist
LINE 5: release_year public.year OPTIONS (column_name 'release_yea...
^
QUERY: CREATE FOREIGN TABLE film (
film_id integer OPTIONS (column_name 'film_id') NOT NULL,
title character varying(255) OPTIONS (column_name 'title') COLLATE pg_catalog."default" NOT NULL,
description text OPTIONS (column_name 'description') COLLATE pg_catalog."default",
release_year public.year OPTIONS (column_name 'release_year'),
language_id smallint OPTIONS (column_name 'language_id') NOT NULL,
rental_duration smallint OPTIONS (column_name 'rental_duration') NOT NULL,
rental_rate numeric(4,2) OPTIONS (column_name 'rental_rate') NOT NULL,
length smallint OPTIONS (column_name 'length'),
replacement_cost numeric(5,2) OPTIONS (column_name 'replacement_cost') NOT NULL,
rating public.mpaa_rating OPTIONS (column_name 'rating'),
last_update timestamp without time zone OPTIONS (column_name 'last_update') NOT NULL,
special_features text[] OPTIONS (column_name 'special_features') COLLATE pg_catalog."default",
fulltext tsvector OPTIONS (column_name 'fulltext') NOT NULL
) SERVER dvdrental
OPTIONS (schema_name 'public', table_name 'film');
CONTEXT: importing foreign table "film"
SQL state: 42704
When I look at line 5, I get why postgres is throwing the error. It's trying to create the column release_year with the type public.year. However, that's not a valid type (like INTEGER) and therefore I get the error.
Still, how can I fix it? I mean, how can I override the data type that postgres is trying to set for this specific column?