pgschema

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Col

type Col struct {
	// contains filtered or unexported fields
}

Col is the name and index of a column in a table

type ForeignKey

type ForeignKey struct {
	// contains filtered or unexported fields
}

ForeignKey represents a foreign key relationship the ForeignKey named "name" indicates that the columns "cols" on Table "foreignTable" references the primary key columns "cols" of "primaryTable"

type PrimaryKey

type PrimaryKey struct {
	// contains filtered or unexported fields
}

PrimaryKey is the name of a primary key field in a table

type Schema

type Schema struct {
	Tables  []*Table
	XLogPos pglogrepl.LSN
}

Schema represents a set of Tables and the tx log sequence number (XLogPos) at which they were fetched

func SyncSchema

func SyncSchema(ctx context.Context, conn *pgxpool.Pool, includedTables ...string) (*Schema, error)

SyncSchema generates a simplified representation of the postgres schema It assumes that conn has the `replication` flag set so that it can fetch the current tx log sequence number, and will error if not.

func (*Schema) InternalMapping

func (s *Schema) InternalMapping(external []config.TableMapping) []config.InternalTableMapping

InternalMapping converts a TableMapping config to an InternalTableMapping by using the information on the Schema.

func (*Schema) ToConfig

func (s *Schema) ToConfig() *config.Config

func (*Schema) ToTableMapping

func (s *Schema) ToTableMapping() []config.TableMapping

ToTableMapping generates a provisional TableMapping config based on an existing schema. This can be a good starting point for developing a postgres import config.

func (*Schema) ToZedSchema

func (s *Schema) ToZedSchema() (zedSchema string)

ToZedSchema generates an (example) zed schema for the postgres schema

type Table

type Table struct {
	// ID is the int table identifier in postgres
	ID          uint32
	Name        string
	PrimaryKeys PrimaryKey
	ForeignKeys []ForeignKey
	Cols        []Col
}

Table is associated with a set of PrimaryKeys and a set of ForeignKeys

Jump to

Keyboard shortcuts

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