stdmigrate

package
v0.0.264 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stdmigrate provides some utilities for more readable migrations code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(ctx context.Context, tx Tx, query string, args ...any) sql.Result

Exec executes the sql or panics on failure.

func ExecFile

func ExecFile(ctx context.Context, tx Tx, files fs.FS, filename string) sql.Result

ExecFile rexecutes sql from a file.

func Up

func Up[T Tx](f func(ctx context.Context, tx T)) func(ctx context.Context, tx T) error

Up is a utility for running migrations such that panics are turned into errors. It gives it more of a scripting feel for easier reading.

Types

type Tx

type Tx interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

Tx interface narrows what we allow to be used for migrations.

Jump to

Keyboard shortcuts

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