Documentation
¶
Overview ¶
Package storagecheck states which database schemas a build can operate on and verifies a supplied SQLite file against that policy before a daemon serves requests or restores work. It never migrates or repairs a database: an incompatible file is refused with the action its operator has to take.
Index ¶
Constants ¶
const ( MinimumDispatcherVersion int64 = 7 MinimumExecutorVersion int64 = 4 )
Minimum supported schema versions. Every version from the minimum up to the version the packaged migrations produce is served without a migration step. Raise the minimum together with a migration the daemon's queries depend on: an older database can then no longer answer them and must be refused instead of failing later during service.
Variables ¶
var ( ErrAbsent = errors.New("database not found") ErrUnknown = errors.New("unknown database") ErrUnreadable = errors.New("unreadable database") ErrOutdated = errors.New("outdated database schema") ErrNewer = errors.New("newer database schema") ErrIncomplete = errors.New("incomplete database schema") )
Reasons a database is refused. An absent database, a readable one that is not ours, and a storage fault are separate answers for an operator.
Functions ¶
func Check ¶
Check verifies the database at path against the schema policy of the role. It opens the file read-only and leaves its bytes unchanged even when it refuses it, so a refused database can still be inspected or restored. A database in WAL mode can still gain the usual -wal and -shm companions.
Types ¶
type Policy ¶
type Policy struct {
Role Role
// Minimum is the oldest schema version the daemon serves.
Minimum int64
// Current is the version the packaged migrations produce. A database
// beyond it was written by a newer Debuglet.
Current int64
// Identity lists tables, with columns, that only this role's database
// has and that it has carried since its early migrations. They are
// checked before the version, so a path pointing at the other role's
// database is reported as the wrong file rather than as a wrong version.
Identity map[string][]string
// Tables lists the tables the supported schema must contain, with the
// columns that distinguish a completely applied schema from one whose
// migrations stopped halfway.
Tables map[string][]string
}
Policy is the schema contract of one database for this build.