Surgex v2.1.1 Surgex.DataPipe.ForeignDataWrapper

Configures a PostgreSQL Foreign Data Wrapper linkage between two repos.

Specifically, it executes the following steps:

  • adds postgres_fdw extension to local repo
  • (re)creates server and user mapping based on current remote repo’s config
  • copies remote repo’s schema to local repo (named with underscored repo module name)

Everything is executed in one transaction, so it’s safe to use while existing transactions that depend on connection to foreign repo and its schema are running in the system (based on https://robots.thoughtbot.com/postgres-foreign-data-wrapper).

Usage

Refer to Surgex.DataPipe for a complete data pipe example.

Summary

Functions

Links source repo to a given foreign repo

Puts a foreign repo prefix (aka. schema) in a given Repo query

Functions

init(source_repo, foreign_repo)

Links source repo to a given foreign repo.

prefix(schema, foreign_repo)

Puts a foreign repo prefix (aka. schema) in a given Repo query.

After calling this function, a given query will target tables from the previously linked repo instead of Repo.