Electric.Postgres.Configuration (electric v1.0.19)

View Source

Module for functions that configure Postgres in some way using a provided connection.

Summary

Functions

Configure the publication to include all relevant tables, also setting table identity to FULL if necessary. Return a list of tables that could not be configured.

Get Postgres server version

Types

Functions

configure_publication!(conn, previous_relations, new_filters, pg_version, publication_name)

@spec configure_publication!(
  Postgrex.conn(),
  [Electric.oid_relation()],
  filters(),
  non_neg_integer(),
  String.t()
) :: relations_failed_to_configure
when relations_failed_to_configure: [Electric.oid_relation()]

Configure the publication to include all relevant tables, also setting table identity to FULL if necessary. Return a list of tables that could not be configured.

Any tables that were previously configured but were either renamed or dropped will not be automatically re-added to the publication. Mentioned tables that have been renamed or dropped will be returned as a list.

previous_relations argument is used to figure out renamed/dropped table based on table OIDs.

Important: this function should not be ran in a transaction, because it starts multiple internal transactions that are sometimes expected to fail.

Raises if it fails to configure all the tables in the expected way.

get_pg_version(conn)

@spec get_pg_version(Postgrex.conn()) :: {:ok, non_neg_integer()} | {:error, term()}

Get Postgres server version

get_publication_tables(conn, publication)

@spec get_publication_tables(Postgrex.conn(), String.t()) :: [Electric.relation()]