store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package store is part of the Redoubt control plane. See CLAUDE.md for its role.

Package store owns the SQLite database: opening it with the right pragmas (WAL, foreign keys, busy timeout), running the embedded goose migrations at startup, and exposing the sqlc-generated query layer (internal/store/db). No other package writes SQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime renders t as RFC 3339 (nanoseconds, UTC).

func Now

func Now() string

Now returns the canonical timestamp string stored in the database.

func ParseTime

func ParseTime(s string) (time.Time, error)

ParseTime parses a stored timestamp.

Types

type Store

type Store struct {
	DB      *sql.DB
	Queries *db.Queries
	// contains filtered or unexported fields
}

Store wraps the database handle and the generated queries.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open opens (creating if needed) the SQLite database at path, applies pragmas, and runs all pending migrations. The file is created with mode 0600.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) error

Migrate applies all pending embedded migrations.

func (*Store) MigrateDownTo

func (s *Store) MigrateDownTo(ctx context.Context, version int64) error

MigrateDownTo rolls back to the given version (0 = everything). Used by tests only.

func (*Store) Path

func (s *Store) Path() string

Path returns the database file path.

func (*Store) Version

func (s *Store) Version(ctx context.Context) (int64, error)

Version returns the current migration version.

func (*Store) WithTx

func (s *Store) WithTx(ctx context.Context, fn func(q *db.Queries, tx *sql.Tx) error) error

WithTx runs fn inside a transaction, committing on nil error and rolling back otherwise.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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