wpg

package
v0.1.9-0...-aea8d42 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indexes

func Indexes(ctx context.Context, pg Conn, table string) []map[string]any

func LockHash

func LockHash(s string) int64

Uses fnva to compute a hash This is an expensive function since it uses a global map and a mutex to check if there was a hash collision.

func NewPool

func NewPool(ctx context.Context, url string) (*pgxpool.Pool, error)

func RowEstimate

func RowEstimate(ctx context.Context, pg Conn, table string) string

func TableSize

func TableSize(ctx context.Context, pg Conn, table string) string

func TestPG

func TestPG(tb testing.TB, schema string) *pgxpool.Pool

Types

type Column

type Column struct {
	Name string `db:"column_name"json:"name"`
	Type string `db:"data_type"json:"type"`
}

type Conn

type Conn interface {
	CopyFrom(context.Context, pgx.Identifier, []string, pgx.CopyFromSource) (int64, error)
	Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
	QueryRow(context.Context, string, ...any) pgx.Row
	Query(context.Context, string, ...any) (pgx.Rows, error)
}

type DiffDetails

type DiffDetails struct {
	Remove []Column
	Add    []Column
}

func Diff

func Diff(
	ctx context.Context,
	pg Conn,
	tableName string,
	cols []Column,
) (DiffDetails, error)

type Table

type Table struct {
	Name    string   `json:"name"`
	Columns []Column `json:"columns"`

	DisableUnique bool       `json:"disable_unique"`
	Unique        [][]string `json:"unique"`
	Index         [][]string `json:"index"`
}

func (Table) DDL

func (t Table) DDL() []string

func (Table) Migrate

func (t Table) Migrate(ctx context.Context, pg Conn) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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