upgrade

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package upgrade implements the "admin upgrade" command, which migrates the nitpicking database from its current schema version to v3. The command chains the v1→v2 and v2→v3 migrations in sequence so that a single invocation carries a database from any supported source version to the current version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmd

func NewCmd(f *cmdutil.Factory, runFn ...func(context.Context, RunInput) error) *cli.Command

NewCmd constructs the "admin upgrade" command, which checks the database schema version and applies any pending migrations to bring it to v3. An optional runFn parameter replaces the default Run for testing; when injected, the service is not constructed and the runFn receives only the IOStreams fields of RunInput (Svc is nil).

func Run

func Run(ctx context.Context, input RunInput) error

Run executes the upgrade workflow: checks the schema version and, when the database is below v3, applies the pending migrations in sequence. A v1 database receives both the v1→v2 and v2→v3 steps; a v2 database receives only the v2→v3 step; a v3 database is reported as up to date immediately.

Both migration functions are safe to call on an already-migrated database (v1→v2 is a no-op on a v2 database because the SQL changes are idempotent, and v2→v3 has an explicit PRAGMA table_info guard). The chained call therefore always applies the v1→v2 step first, followed by v2→v3, so that a v1 database reaches v3 in a single invocation without requiring the caller to know the source version.

Types

type RunInput

type RunInput struct {
	// Svc is the application service through which schema migration operations
	// are invoked. The upgrade command never imports a concrete storage adapter;
	// all migration capability is accessed via this driving port interface.
	Svc driving.Service

	// JSONOutput requests machine-readable JSON output when true.
	JSONOutput bool

	// Out receives the human-readable or JSON output.
	Out io.Writer

	// ColorScheme provides terminal colour helpers for human-readable output.
	ColorScheme *iostreams.ColorScheme
}

RunInput holds all parameters for the upgrade command's core logic, decoupled from CLI flag parsing so it can be tested directly.

Jump to

Keyboard shortcuts

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