Surgex.DataPipe.ForeignDataWrapper (Surgex v5.0.0) View Source

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.

Link to this section Summary

Functions

Links source repo to a given foreign repo.

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

Link to this section Functions

Link to this function

init(source_repo, foreign_repo)

View Source

Links source repo to a given foreign repo.

Link to this function

init_script(server, schema, config)

View Source
Link to this function

prefix(query, foreign_repo)

View Source

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.

Link to this function

update_script(server, schema, config)

View Source