I am trying to create a link between postgres databases on my local, using FDW. Here is my code to create this link:
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
CREATE SERVER IF NOT EXISTS TEST_SERVER FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '127.0.0.1', dbname 'TestDatabase', port '5432');
CREATE USER MAPPING IF NOT EXISTS FOR postgres SERVER TEST_SERVER OPTIONS (user 'postgres', password 'postgres');
CREATE FOREIGN TABLE IF NOT EXISTS TEST_PUBLIC.TEST_TABLE(
ID INT NOT NULL,
VALUE VARCHAR(11) NOT NULL
) SERVER TEST_SERVER;
TEST table exists on TestDatabase, and test_public schema exists on the current database I'm creating the FDW on. When I originally created this and tested it I could see the objects with no issues, however part of my development process (for this specific project) is to drop all objects in the current and rerun from the ground up so when we move this to a new environment we know from start to finish everything is solid.
The problem I am having is I can no longer see the foreign table "TEST_TABLE".
When I run this:
SELECT * FROM information_schema.tables WHERE table_schema = 'test_public'
I get the following returned:
table_catalog table_schema table_name table_type
TestDatabase test_public test_table FOREIGN
But when I select from the table test_public.test_table I get the following Error:
relation "test_public.test_table" does not exist
I was able to figure out all of my woes along the way, but even after running this step by step instead of a full deployment I can't seem to access the foreign table anymore. Any suggestions as to what I am missing?