db

package
v0.0.0-...-2943bdd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prepare

func Prepare(conn *pgx.Conn, schemas []string, includeTables, excludeTables []string) error

Prepare prepares the database for capturing changesets. This will setup:

  • new `warp_pipe` schema
  • new `changesets` table in the `warp_pipe` schema
  • new TRIGGER function to be fired AFTER an INSERT, UPDATE, or DELETE on a table
  • registers the trigger with all configured tables in the source schema

func PrepareForDataIntegrityChecks

func PrepareForDataIntegrityChecks(conn *pgx.Conn) error

func Teardown

func Teardown(conn *pgx.Conn) error

Teardown removes the `warp_pipe` schema and all associated tables and functions.

Types

type Table

type Table struct {
	Name       string
	Schema     string
	PKeyName   string
	PKeyFields map[int]string
}

func GenerateTablesList

func GenerateTablesList(conn *pgx.Conn, schemas, includeTables, excludeTables []string) ([]Table, error)

GenerateTablesList using the includes and excludes list. If no tables are specified in the includes list, obtain the complete list from Postgres using the supplied schemas. If any of the included tables are listed as excluded, remove them from the list.

type Wal2JSONChange

type Wal2JSONChange struct {
	ID           int64            `json:"id"`
	Kind         string           `json:"kind"`
	Schema       string           `json:"schema"`
	Table        string           `json:"table"`
	ColumnNames  []string         `json:"columnnames"`
	ColumnTypes  []string         `json:"columntypes"`
	ColumnValues []interface{}    `json:"columnvalues"`
	OldKeys      *Wal2JSONOldKeys `json:"oldkeys"`
}

Wal2JSONChange represents a changeset within a Wal2JSONMessage.

type Wal2JSONMessage

type Wal2JSONMessage struct {
	Changes []*Wal2JSONChange `json:"change"`
	NextLSN string            `json:"nextlsn"`
}

Wal2JSONMessage represents a wal2json message object.

type Wal2JSONOldKeys

type Wal2JSONOldKeys struct {
	KeyNames  []string      `json:"keynames"`
	KeyTypes  []string      `json:"keytypes"`
	KeyValues []interface{} `json:"keyvalues"`
}

Wal2JSONOldKeys represents the `oldkeys` object in a Wal2JSON change

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL