Documentation
¶
Overview ¶
Package sqlite provides utility functions for SQLite database operations such as online backup and integrity verification.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backup ¶
Backup creates a safe online backup of a SQLite database using VACUUM INTO. VACUUM INTO produces a clean, defragmented copy of the database while allowing concurrent reads on the source. The backup file is named with a timestamp suffix (e.g., "loom.db.backup.20260224T153000"). On failure, any partially written backup file is removed before returning.
func VerifyBackup ¶
VerifyBackup opens a SQLite database file and runs PRAGMA integrity_check to confirm the file is a valid, uncorrupted SQLite database.
Types ¶
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator manages SQLite schema migrations using embedded SQL files. Unlike the PostgreSQL migrator which uses advisory locks, this uses a sync.Mutex to prevent concurrent migration execution within the process.
func NewMigrator ¶
NewMigrator creates a new migrator with embedded SQL migrations. It sets PRAGMA busy_timeout = 5000 on the database to handle lock contention.
func (*Migrator) CurrentVersion ¶
CurrentVersion returns the highest applied migration version. Returns 0 if the schema_migrations table does not exist yet.
func (*Migrator) MigrateDown ¶
MigrateDown rolls back the specified number of migrations.