migrate

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package migrate provides versioned schema upgrade and repair for .cloop directories. It detects the current schema version, runs idempotent migration steps, and repairs common corruption such as orphaned snapshot files and missing columns.

Index

Constants

View Source
const CurrentVersion = 2

CurrentVersion is the highest schema version this binary understands.

Variables

This section is empty.

Functions

func NeedsUpgrade

func NeedsUpgrade(workDir string) bool

NeedsUpgrade returns true when the .cloop directory exists but the schema version is behind CurrentVersion. It never returns an error on missing dirs.

func Run

func Run(opts Options) (*Report, []RepairReport, error)

Run detects the schema version, applies all pending migrations, and repairs common corruption. It returns a Report describing what happened.

Types

type Options

type Options struct {
	WorkDir     string
	DryRun      bool
	FromVersion int // -1 = auto-detect
}

Options controls migration behaviour.

type RepairReport

type RepairReport struct {
	Kind   string // "orphan_snapshot", "missing_column", "invalid_config_key"
	Detail string
	Fixed  bool
}

RepairReport describes a single repair action.

type Report

type Report struct {
	FromVersion    int
	ToVersion      int
	DryRun         bool
	Steps          []StepReport
	Warnings       []string
	RowsMigrated   int
	FilesConverted int
}

Report summarises what was (or would be) done during a migration run.

type StepReport

type StepReport struct {
	From    int
	To      int
	Applied bool   // false when already up-to-date
	Note    string // human-readable summary
}

StepReport is the outcome of a single versioned migration step.

Jump to

Keyboard shortcuts

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