pgmigrate

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tables added in v0.5.0

func Tables(ctx context.Context, pool *pgxpool.Pool) ([]string, error)

Tables lists every base table visible in the current schema, framework and product tables alike, sorted (P1-1, orkome pack rollout): migrations know the DDL surface, so test-isolation code (TRUNCATE lists, allowlist guards) should derive its table list from here instead of hand-maintaining a second inventory that silently rots every time a migration adds a table. The pgmigrate bookkeeping table (schema_migrations) is excluded.

func Up

func Up(ctx context.Context, pool *pgxpool.Pool, fsys fs.FS, subdir string) error

Types

type Hook

type Hook func(ctx context.Context, conn *pgxpool.Conn) error

type Migrator

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

func New

func New(pool *pgxpool.Pool, fsys fs.FS, subdir string) *Migrator

func (*Migrator) Down

func (m *Migrator) Down(ctx context.Context, limit int) ([]string, error)

Down rolls back the N most recently applied migrations (limit > 0), or the entire applied history for a negative limit. It is NOT a goose-style "down-to-version": pass a COUNT, never a target version (orkome field report — a round-trip test written with the goose mental model was wrong from birth). limit == 0 is rejected: the old silent reading of 0 was "roll back everything", which is a real-accident generator.

func (*Migrator) RegisterPreHook

func (m *Migrator) RegisterPreHook(version string, h Hook)

func (*Migrator) Status

func (m *Migrator) Status(ctx context.Context) ([]StatusRow, error)

func (*Migrator) Up

func (m *Migrator) Up(ctx context.Context, limit int) ([]string, error)

type StatusRow

type StatusRow struct {
	Version   string
	Applied   bool
	AppliedAt *string

	Orphan bool
}

Jump to

Keyboard shortcuts

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