database

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachedMigrationError

func CachedMigrationError() string

CachedMigrationError returns the error message captured when the most recent migration attempt failed at startup. Empty string means migrations either succeeded or were never run.

func CachedMigrationVersion

func CachedMigrationVersion() (uint, bool, bool)

CachedMigrationVersion returns the migration version captured at startup. Returns (version, dirty, ok). ok is false if the version was never captured.

Note: when migrations fail mid-way, the cache may still be populated via a best-effort m.Version() call inside RunMigrationsWithOptions so the system info endpoint can surface the partial state. Check CachedMigrationError() to distinguish a clean version reading from a recorded-after-failure one.

func GetMigrationVersion

func GetMigrationVersion() (uint, bool, error)

GetMigrationVersion returns the current migration version

func RunMigrations

func RunMigrations(dsn string) error

RunMigrations executes all pending database migrations This should be called during application startup

func RunMigrationsWithOptions

func RunMigrationsWithOptions(dsn string, opts MigrationOptions) error

RunMigrationsWithOptions executes all pending database migrations with custom options

Types

type MigrationOptions

type MigrationOptions struct {
	// AutoRecoverDirty when true, automatically attempts to recover from dirty state
	// by forcing to the previous version and retrying the migration
	AutoRecoverDirty bool

	// SQLiteDBPath is the raw filesystem path to the SQLite database file.
	// When set, the migrator opens the DB directly via sql.Open instead of
	// parsing a URL-based DSN, which avoids breakage when the path contains
	// spaces (e.g. macOS "Application Support").
	SQLiteDBPath string
}

MigrationOptions configures migration behavior

Jump to

Keyboard shortcuts

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