migration

package
v1.67.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package migration provides database migration functionality using the goose library. It manages schema evolution by applying pending SQL or Go migrations from a specified directory and tracks migration versions.

Index

Constants

View Source
const (
	DialectPostgreSQL = goose.DialectPostgres
	// DialectSqlite3 represents the SQLite3 dialect for migrations.
	DialectSqlite3 = goose.DialectSQLite3
	// DialectClickhouse represents the ClickHouse dialect for migrations.
	DialectClickhouse = goose.DialectClickHouse
)

DialectPostgreSQL represents the PostgreSQL dialect for migrations.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

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

Runner manages database migrations using the goose library. It applies pending migrations from a specified directory and tracks migration versions.

func NewRunner

func NewRunner(
	dialect goose.Dialect,
	migrationDir string,
	logger log.Logger,
) Runner

NewRunner creates a new migration Runner with the specified dialect, migration directory, and logger.

func (Runner) Run

func (r Runner) Run(ctx context.Context, db *sql.DB, gooseOpts ...goose.ProviderOption) error

Run applies all pending migrations to the database. It logs the current database version, lists all migrations with their status, and applies any pending migrations. Returns an error if the migration directory does not exist, migrations cannot be loaded, or if applying migrations fails.

Jump to

Keyboard shortcuts

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