db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireInstanceLock

func AcquireInstanceLock(dbPath string) (*os.File, error)

AcquireInstanceLock takes an exclusive non-blocking flock on `<dir>/shellboto.lock`, where dir is the parent of the configured DB path. Returns the held *os.File — caller MUST keep it alive for the process lifetime (closing it releases the lock). On conflict (another instance holding the lock) returns an error with a clear operator-facing message.

Without this, two shellboto processes pointed at the same state.db would race on the audit hash chain — our `logMu` mutex serializes audit writes within a process but not across processes.

Uses a dedicated lockfile rather than flock-ing state.db directly to avoid interfering with SQLite's own POSIX advisory locks on the DB file. Kernel auto-releases on process death (clean exit or crash), so stale lockfiles are never a problem.

func Close

func Close(db *gorm.DB) error

Close closes the underlying *sql.DB.

func Migrate

func Migrate(db *gorm.DB) error

Migrate runs GORM's AutoMigrate across every model, plus a small set of explicit one-off drops for columns that were renamed in earlier schema changes. AutoMigrate itself is additive only (never drops); the drops here are idempotent on fresh DBs.

func Open

func Open(path string) (*gorm.DB, error)

Open creates or opens the SQLite DB, runs AutoMigrate for every model, and returns the GORM handle. Callers build repositories on top of the returned *gorm.DB.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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