migrations

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 6 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

View Source
var RegistryCache = []migrate.Migration{
	{Version: 1, Name: "cache_schema", Up: upCacheSchema},
}

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.

View Source
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},
}

RegistryDatabase lists every migration for the durable database file in order. Version numbers are never reused.

View Source
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

func CopyLegacyCacheTables(ctx context.Context, primary, cache *gorm.DB) error

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.

func LegacySingleFile

func LegacySingleFile(primary *gorm.DB) bool

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.

Jump to

Keyboard shortcuts

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