Skip to main content

One post tagged with "materialized-view"

View All Tags

Mocking postgres_fdw foreign servers for local dev and CI

Question

Schemas that use postgres_fdw reference an upstream PostgreSQL server (SERVER, USER MAPPING, FOREIGN TABLE). That upstream server is often reachable only from inside the VPC of environments such as staging or production: local workstations and CI runners have no network path to it.

Working with such schemas in Atlas, whether for schema planning, schema testing, or simulating the real setup locally, triggers an FDW connection attempt on the dev-database that fails with errors such as:

08001 could not connect to server "upstream_db"

A common case is a materialized view that selects from a foreign table, which opens the FDW connection at CREATE time. What is the recommended pattern for stubbing the foreign server so that schema design, plan, lint, and diff run hermetically against the dev-database?