settingsmigration

package
v0.16.21 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// SchemaVersionKey records the migrated settings schema version as a
	// JSON-encoded number in the settings table.
	SchemaVersionKey = "settings_schema_version"
	// CurrentSchemaVersion is the target version written by Apply.
	CurrentSchemaVersion = 1
)

Settings schema version bookkeeping. The settings table keeps the legacy *_cron / mode keys as the single runtime source of truth; v2 schedule keys are append-only semantic mirrors produced by this migration.

Variables

This section is empty.

Functions

This section is empty.

Types

type MigrationItem

type MigrationItem struct {
	Task        string                 `json:"task"`
	LegacyKey   string                 `json:"legacyKey"`
	LegacyValue string                 `json:"legacyValue"`
	V2Key       string                 `json:"v2Key"`
	Schedule    scheduler.ScheduleSpec `json:"schedule"`
}

MigrationItem describes one legacy -> v2 schedule conversion.

type MigrationPlan

type MigrationPlan struct {
	CurrentVersion        int             `json:"currentVersion"`
	TargetVersion         int             `json:"targetVersion"`
	Pending               int             `json:"pending"`
	CustomCount           int             `json:"customCount"`
	LegacyFieldsPreserved bool            `json:"legacyFieldsPreserved"`
	Items                 []MigrationItem `json:"items"`
}

MigrationPlan is the top-level flat preview of a pending migration.

func BuildPlan

func BuildPlan(db *sqlx.DB) (MigrationPlan, error)

BuildPlan computes the append-only migration plan from the current settings table. It never writes and never modifies legacy keys.

type MigrationResult

type MigrationResult struct {
	MigrationPlan
	Applied int `json:"applied"`
}

MigrationResult extends MigrationPlan with the number of rows actually written by Apply.

func Apply

func Apply(db *sqlx.DB) (MigrationResult, error)

Apply writes the pending v2 schedule keys and the schema version in a single transaction. It only appends (never deletes or modifies legacy keys), skips already-present v2 keys, and is a no-op when everything is already migrated.

Jump to

Keyboard shortcuts

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