Documentation
¶
Overview ¶
Package migrations owns numbered SQLite schema changes. Each migration declares its own snapshot structs and never imports internal/db/record so later model changes cannot rewrite history.
Split storage owns migration version 2 plus the cache-file schema.
The durable database keeps version 1 untouched and gains version 2, which drops the moved tables and removes TTL plugin storage rows (copied to the cache file beforehand by CopyLegacyCacheTables). The cache file runs its own registry with its own history table: version 1 creates every cache table. Cache snapshots drop cross-file associations: SQLite cannot enforce foreign keys across files, so cache rows reference durable parents softly. Associations inside the cache file (batch children, metric dimensions, model info children) keep their cascade constraints.
Events schema owns migration version 1 of the events file plus the prune helper inputs. The events file holds operator telemetry only: event records with free-form metadata keys. Deleting the file while stopped loses log history and nothing else.
Plugin disabled state owns migration version 3 of the durable database.
Version 1 stays untouched. Version 3 adds the operator-owned disabled flag to the plugins table so dashboard toggles persist across restarts. Disabled plugins stay inventoried but leave the in-memory type registry.
Proxy max checks owns migration version 4 of the durable database.
Version 4 adds the operator-chosen cap on parallel proxy checks to the instance settings row. Zero keeps the adaptive default.
Proxy switches owns migration version 5 of the durable database.
Version 5 adds the two proxy on/off switches to the instance settings row, stored inverted so existing rows keep the proxy subsystem enabled.
Plugin identity owns migration version 6 of the durable database.
Version 6 rebuilds plugin identifiers to the author/plugin-name format. The previous identifier embedded the installation source (repository id or "manual"), which blocked installing the same plugin from another source. The new identifier derives from the manifest only, so later installs from any source with the same author and plugin name override the previous installation. The identity of each row comes from author and display name; a collision keeps the most recently updated row and deletes the losers with their child rows.
Identifier moves replay rows instead of updating identifiers in place. The schema has no ON UPDATE CASCADE, so an in-place parent identifier update and a child identifier update each violate the immediate foreign-key checks under any ordering. A child row reinsertion after the parent copy always references an existing parent, so no deferred foreign keys are needed.
Encrypt credentials owns migration version 7 of the durable database.
Version 7 seals every plaintext credentials.data value with the installed credential key (AES-256-GCM, credentialcipher). From this version on the record serializer reads sealed values only, so the migration must run before any credential read. A missing key fails the migration and with it startup: plaintext never survives silently.
Dashboard password owns migration version 8 of the durable database and version 2 of the cache database.
The dashboard has one operator and no accounts: one password hash lives in the single-row dashboard_password table. Durable version 8 creates it, moves one hash out of admin_users (the "admin" account, else the oldest one), then drops admin_users and the instance_settings.bootstrapped flag: a stored hash is the only "configured" state. Cache version 2 recreates sessions without the username column, so existing dashboard sessions end once.
Provider seed icons owns migration version 9 of the durable database.
Seeded provider rows (UI-readonly) held a copy of the icon declared by their plugin type. The copy never followed plugin updates, so the icon now resolves from the plugin type at read time and seeded rows keep none.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RegistryCache = []migrate.Migration{
{Version: 1, Name: "cache_schema", Up: upCacheSchema},
{Version: 2, Name: "session_without_username", Up: upCacheSessionWithoutUsername},
}
RegistryCache lists every migration for the cache database file in order. Version numbers are scoped per file: each file owns its own history table, so the cache lineage starts at 1 independently of the primary lineage.
var RegistryDatabase = []migrate.Migration{
{Version: 1, Name: "initial_schema", Up: upInitialSchema},
{Version: 2, Name: "split_storage", Up: upSplitStorage},
{Version: 3, Name: "plugin_disabled", Up: upPluginDisabled},
{Version: 4, Name: "proxy_max_checks", Up: upProxyMaxChecks},
{Version: 5, Name: "proxy_switches", Up: upProxySwitches},
{Version: 6, Name: "plugin_identity", Up: upPluginIdentity},
{Version: 7, Name: "encrypt_credentials", Up: upEncryptCredentials},
{Version: 8, Name: "dashboard_password", Up: upDashboardPassword},
{Version: 9, Name: "provider_seed_icons", Up: upProviderSeedIcons},
}
RegistryDatabase lists every migration for the durable database file in order. Version numbers are never reused.
var RegistryEvents = []migrate.Migration{
{Version: 1, Name: "events_schema", Up: upEventsSchema},
}
RegistryEvents lists every migration for the events database file in order. Version numbers are scoped per file.
Functions ¶
func CopyLegacyCacheTables ¶
CopyLegacyCacheTables copies every moved table from a single-file primary database into the cache database. Inserts upsert so a repeated run after an interrupted startup converges instead of duplicating. Only plugin storage rows with a TTL move; durable rows stay in the primary file. Sessions never move: the cache sessions table has no username column since cache version 2, and an operator signs in again.
func LegacySingleFile ¶
LegacySingleFile reports whether the primary database still holds the single-file layout. The sessions table only ever lived in the primary file before the split, so its presence marks a database that predates version 2. Fresh and already-split files never carry it.
Types ¶
This section is empty.