migration

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package migration runs SQL schema migrations via goose for PostgreSQL and ClickHouse.

On PostgreSQL it uses advisory locks so only one instance applies migrations at a time.

Index

Constants

View Source
const (
	ErrCodeGooseFolderNotFound     = "GS-001"
	ErrCodeGooseFolderOpen         = "GS-002"
	ErrCodeGooseMigrationLock      = "GS-003"
	ErrCodeGooseMigrationUnLock    = "GS-004"
	ErrCodeGooseMigrationDown      = "GS-005"
	ErrCodeGooseMigrationUp        = "GS-006"
	ErrCodeGooseMigrationGetVer    = "GS-007"
	ErrCodeGooseUnsupportedDialect = "GS-008"
	ErCodeGoosePing                = "GS-009"
)
View Source
const (
	DialectPostgres   = "postgres"
	DialectClickHouse = "clickhouse"
)

Variables

View Source
var (
	ErrGooseMigrationUp = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeGooseMigrationUp, "").Wrap(cause).Err()
	}
	ErrGooseMigrationDown = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeGooseMigrationDown, "").Wrap(cause).Err()
	}
	ErrGooseMigrationGetVer = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeGooseMigrationGetVer, "").Wrap(cause).Err()
	}
	ErrGooseFolderNotFound = func(path string) error {
		return jet.NewAppErrBuilder(ErrCodeGooseFolderNotFound, "folder not found %s", path).Err()
	}
	ErrGooseFolderOpen = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeGooseFolderOpen, "folder open").Wrap(cause).Err()
	}
	ErrGooseMigrationLock = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeGooseMigrationLock, "locking before migration").Wrap(cause).Err()
	}
	ErrGooseMigrationUnLock = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeGooseMigrationUnLock, "unlocking after migration").Wrap(cause).Err()
	}
	ErrGooseUnsupportedDialect = func(dialect string) error {
		return jet.NewAppErrBuilder(ErrCodeGooseUnsupportedDialect, "unsupported dialect: %s", dialect).Err()
	}
	ErGoosePing = func(cause error) error {
		return jet.NewAppErrBuilder(ErCodeGoosePing, "ping").Wrap(cause).Err()
	}
)

Functions

This section is empty.

Types

type Migration

type Migration interface {
	// Up applies all migrations up to the final version
	Up() error
	// Down rollbacks single version
	Down() error
}

Migration allows applying database migrations

func NewMigration

func NewMigration(db *sql.DB, source string, logger jet.CLoggerFunc, dialect string) Migration

Jump to

Keyboard shortcuts

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