db

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package db provides SQLite-backed storage for nightshift state and snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentVersion

func CurrentVersion(db *sql.DB) (int, error)

CurrentVersion returns the current schema version (0 if no migrations applied).

func DefaultPath

func DefaultPath() string

DefaultPath returns the default database path.

func Migrate

func Migrate(db *sql.DB) error

Migrate runs all pending migrations inside transactions.

Types

type DB

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

DB wraps the SQLite connection and path.

func Open

func Open(dbPath string) (*DB, error)

Open opens or creates the database, applies pragmas, and runs migrations.

func (*DB) Close

func (d *DB) Close() error

Close closes the underlying database connection.

func (*DB) SQL

func (d *DB) SQL() *sql.DB

SQL returns the raw *sql.DB for advanced usage.

type Migration

type Migration struct {
	Version     int
	Description string
	SQL         string
}

Migration represents a single schema change.

Jump to

Keyboard shortcuts

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