sqliteutil

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backup added in v0.13.0

func Backup(ctx context.Context, source, destination string, spec Spec) (err error)

Backup copies committed SQLite state, including WAL, into an exclusive new destination. The storage owner must close its database and exclude writers.

func ListUserIndexesTx added in v0.10.0

func ListUserIndexesTx(tx *sql.Tx) ([]string, error)

func ListUserTablesTx

func ListUserTablesTx(tx *sql.Tx) ([]string, error)

func Open

func Open(path string, spec Spec) (*sql.DB, error)

func TableColumnNamesTx added in v0.10.0

func TableColumnNamesTx(tx *sql.Tx, tableName string) ([]string, error)

func TableExistsTx

func TableExistsTx(tx *sql.Tx, tableName string) (bool, error)

Types

type DatabaseTooNewError

type DatabaseTooNewError struct {
	Kind           string
	Version        int
	CurrentVersion int
}

func (*DatabaseTooNewError) Error

func (e *DatabaseTooNewError) Error() string

type DatabaseTooOldError added in v0.10.0

type DatabaseTooOldError struct {
	Kind           string
	Version        int
	MinimumVersion int
}

func (*DatabaseTooOldError) Error added in v0.10.0

func (e *DatabaseTooOldError) Error() string

type Inspection added in v0.13.0

type Inspection struct {
	Exists            bool
	Version           int
	MigrationRequired bool
}

Inspection describes committed product storage without a writable open.

func Inspect added in v0.13.0

func Inspect(path string, spec Spec) (result Inspection, err error)

Inspect reuses the WAL-aware preflight used by Open. It never initializes a missing file or executes migration steps. Owners validate historical shapes through ValidateExisting; current stores also pass their final verifier.

type InvalidMigrationChainError

type InvalidMigrationChainError struct {
	Kind   string
	Reason string
}

func (*InvalidMigrationChainError) Error

type LegacyKindMigration added in v0.10.0

type LegacyKindMigration struct {
	FromKind    string
	FromVersion int
	ToKind      string
	ToVersion   int
	Apply       func(tx *sql.Tx) error
}

LegacyKindMigration converts one explicitly versioned older schema kind into the current schema before normal version migrations run.

type Migration

type Migration struct {
	FromVersion int
	ToVersion   int
	Apply       func(tx *sql.Tx) error
}

type SchemaVerifyError

type SchemaVerifyError struct {
	Kind string
	Err  error
}

func (*SchemaVerifyError) Error

func (e *SchemaVerifyError) Error() string

func (*SchemaVerifyError) Unwrap

func (e *SchemaVerifyError) Unwrap() error

type Spec

type Spec struct {
	Kind           string
	CurrentVersion int
	MinimumVersion int
	Pragmas        []string
	// ValidateExisting runs only for a non-empty existing file, before any writable connection.
	ValidateExisting     func(tx *sql.Tx) error
	Initialize           func(tx *sql.Tx) error
	Migrations           []Migration
	LegacyKindMigrations []LegacyKindMigration
	Verify               func(tx *sql.Tx) error
}

type WrongDatabaseKindError

type WrongDatabaseKindError struct {
	ExpectedKind string
	ActualKind   string
	Existing     []string
}

func (*WrongDatabaseKindError) Error

func (e *WrongDatabaseKindError) Error() string

Jump to

Keyboard shortcuts

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