Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
DB is the global GORM database handle.
Functions ¶
func EncryptionSalt ¶
EncryptionSalt returns this deployment's scrypt salt, generating it the first time the database is used.
The salt is not a secret — it lives in the same file as the data it protects. Its job is to make the derived key specific to this deployment, so that a precomputed table built against a shared salt is worthless here.
It must never change: the key is derived from (passphrase, salt), so a new salt is a new key and every stored credential becomes unreadable. That is also why it is stored with the data rather than in configuration — a database restored from backup brings its own salt with it.
func Open ¶
func Open() error
Open opens the SQLite database, creating parent directories as needed, and runs AutoMigrate for all persistent models.
func VerifyEncryptionCanary ¶
func VerifyEncryptionCanary() error
VerifyEncryptionCanary checks that the key derived at startup is the one this database was encrypted with, and records the canary on first use.
Without it a changed passphrase starts cleanly and fails later, once per migration, as a scatter of unrelated-looking decrypt errors. Here it is one message at startup, before anything runs.
Types ¶
type Meta ¶
type Meta struct {
Key string `gorm:"primaryKey;column:meta_key"`
Value string `gorm:"column:meta_value"`
}
Meta is an internal key/value table for deployment state that has to outlive a restart but is never exposed through the API: the encryption salt and the key canary. It is deliberately not a REST model — nothing here is ever serialised into a response.