Help us shape the future of Go! Take the 2026 Go Developer Survey

migrations

package
v0.0.0-...-3b28b6b Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package migrations embeds the SQL migration files for the kagent database schema and provides the runner that applies them at startup.

Index

Constants

This section is empty.

Variables

Functions

func RunUp

func RunUp(ctx context.Context, config *pgxpool.Config, sources []Source) error

RunUp applies all pending migrations in source order. Each source migrates on its own pool built from config, with the source's schema as its search path.

func VerifyMigrated

func VerifyMigrated(ctx context.Context, config *pgxpool.Config, sources []Source) error

VerifyMigrated checks migration state without database writes.

func Versions

func Versions(src Source) ([]int64, error)

Versions returns the source's migration versions in ascending order. It rejects an empty source and files Goose would misread or that disable transactions.

func WithProvider

func WithProvider(ctx context.Context, config *pgxpool.Config, src Source, fn func(*goose.Provider) error) (retErr error)

WithProvider runs fn while one source lock is held.

Types

type Source

type Source struct {
	Name          string
	Schema        string
	VectorSchema  string
	TrackingTable string
	FS            fs.FS
	Dir           string
	// PreCheck runs before any source migrates, on a pool that uses the
	// caller's configuration rather than this source's search path.
	PreCheck func(ctx context.Context, pool *pgxpool.Pool) error
}

Source describes one migration source. Schema is required: the source's tables and tracking table live there.

func BuiltinSources

func BuiltinSources(vectorEnabled bool) []Source

BuiltinSources returns the built-in migration sources in the default schemas.

func BuiltinSourcesInSchema

func BuiltinSourcesInSchema(vectorEnabled bool, schema, vectorSchema string) []Source

BuiltinSourcesInSchema returns the built-in sources with their table and pgvector schemas selected independently. Empty values use the defaults.

Jump to

Keyboard shortcuts

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