stdmigrate

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 5 Imported by: 0

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