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

database

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package database provides functions to migrate the database.

Index

Constants

View Source
const (
	// DBName is the name of the test database
	DBName = "testdb"
	// DBUser is the username for the root user of the test database
	DBUser = "testuser"
	// DBPass is the password for the root user of the test database
	DBPass = "testpass"
)

Variables

This section is empty.

Functions

func GetMigrate

func GetMigrate(connString string) (*migrate.Migrate, error)

GetMigrate creates a new migrate instance using the embedded migrations

func GetPrimeTemplate added in v0.3.0

func GetPrimeTemplate() ([]byte, error)

GetPrimeTemplate returns the contents of the prime.sql.tmpl template file

func GetVersion

func GetVersion(connString string) (uint, bool, error)

GetVersion returns the current migration version

func MigrateDown

func MigrateDown(_ context.Context, db *pgx.Conn, steps int) error

MigrateDown reverts the last migration

func MigrateUp

func MigrateUp(_ context.Context, db *pgx.Conn) error

MigrateUp executes all pending database migrations

func SetupTestDB

func SetupTestDB(t *testing.T) (*pgx.Conn, func())

SetupTestDB creates a Postgres container using testcontainers and runs all migrations

func SetupTestDBContainer added in v0.3.0

func SetupTestDBContainer(t *testing.T, ctx context.Context) (*pgx.Conn, func())

SetupTestDBContainer creates a Postgres container using testcontainers and returns a connection to the database

Types

This section is empty.

Jump to

Keyboard shortcuts

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