migrate

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package migrate owns supported live schema upgrades. Historical schema decoding belongs to internal/audit and retired layouts are recognized only for refusal, never parsed or relocated here.

Index

Constants

View Source
const LiveSchemaFloor = 50

LiveSchemaFloor is the oldest source generation this binary can operate on.

Variables

This section is empty.

Functions

func Build added in v0.40.0

func Build(ctx context.Context, root string) (applied []string, resultChanges []Change, mutations []FileMutation, returnErr error)

Build produces only registered supported migrations. It never decodes a below-floor source or writes the filesystem; the command composition maps its file mutations to the upgrade journal.

func CheckLive added in v0.40.0

func CheckLive(root string) (int, error)

func CheckLiveGeneration added in v0.40.0

func CheckLiveGeneration(gen int) error

func Current

func Current() int

func CurrentAuthorityPresence added in v0.49.0

func CurrentAuthorityPresence(root string) (currentConfig, currentLock bool, returnErr error)

CurrentAuthorityPresence inspects the two current control entries without following their final path components.

func GateState

func GateState(root string) (string, int, error)

func GateStateForGeneration added in v0.22.0

func GateStateForGeneration(gen int) string

func Generation

func Generation(root string) (int, error)

Generation reads only a current-layout lock schema. Retired layouts receive a typed refusal before their authority representation can be decoded.

func IsRetiredLayout added in v0.40.0

func IsRetiredLayout(err error) bool

IsRetiredLayout makes presentation boundaries distinguish layout refusal from a below-floor current lock without retaining a layout reader.

func LiveSchemaRange added in v0.40.0

func LiveSchemaRange() (int, int)

func ProjectPresent added in v0.11.0

func ProjectPresent(root string) (present bool, returnErr error)

ProjectPresent recognizes current control files and retired layouts without interpreting content or following final path components.

func ProjectPresentFromFiles added in v0.22.0

func ProjectPresentFromFiles(has func(string) bool) bool

Types

type Change added in v0.30.0

type Change struct {
	Text string
}

Change is one ordered semantic fact produced by a migration. It is data for the upgrade owner, not terminal output.

func CurrentSchemaChange added in v0.30.0

func CurrentSchemaChange() Change

CurrentSchemaChange reports the migration domain's proven no-migration state to its terminal owner.

type Changes added in v0.30.0

type Changes struct {
	// contains filtered or unexported fields
}

Changes is the fact collector passed through the supported migration seam.

func (*Changes) Items added in v0.30.0

func (c *Changes) Items() []Change

Items returns a defensive copy of the facts collected by the migration chain.

type FileImage added in v0.49.0

type FileImage struct {
	Present  bool
	Content  []byte
	Mode     os.FileMode
	Children []string
}

FileImage is the exact entry state observed while planning. An absent image has Present false, zero mode, and no content or children. A directory image records its permission mode and sorted direct-child names.

type FileMutation added in v0.40.0

type FileMutation struct {
	Path           string
	Expected       FileImage
	Content        []byte
	Mode           os.FileMode
	Remove         bool
	EmptyDirectory bool
}

FileMutation is a planned regular-file replacement/removal or empty-directory prune with the original preimage that must still be present when committed.

type Migration

type Migration struct {
	To    int
	Name  string
	Build func(context.Context, *ProposedTree, *Changes) ([]FileMutation, error)
}

Migration is one ordered upgrade step for a supported live generation.

type ProposedTree added in v0.40.0

type ProposedTree struct {
	// contains filtered or unexported fields
}

ProposedTree is the read-only tree view supplied to one migration step. It overlays every earlier step's plan on the confined project root, so ordered steps observe the state they are collectively proposing without mutating it.

func (*ProposedTree) PlanEmptyDirectory added in v0.49.0

func (t *ProposedTree) PlanEmptyDirectory(path string, sameStep []FileMutation) (FileMutation, bool, error)

PlanEmptyDirectory returns a prune only when path's proposed direct children are all removed by earlier steps or the supplied same-step plan. The exact current child inventory remains the commit-time stale-plan preimage.

func (*ProposedTree) Read added in v0.40.0

func (t *ProposedTree) Read(path string) ([]byte, os.FileMode, error)

Read returns the proposed bytes and mode for path. A non-regular final entry is rejected because file-image migrations cannot preserve its topology.

type RetiredLayoutError added in v0.40.0

type RetiredLayoutError struct{ Layout string }

RetiredLayoutError identifies a removed layout without decoding its config.

func (*RetiredLayoutError) Error added in v0.40.0

func (e *RetiredLayoutError) Error() string

func (*RetiredLayoutError) Is added in v0.40.0

func (e *RetiredLayoutError) Is(target error) bool

type UpgradeRequiredError added in v0.40.0

type UpgradeRequiredError struct{ Generation, Current int }

func (*UpgradeRequiredError) Error added in v0.40.0

func (e *UpgradeRequiredError) Error() string

Jump to

Keyboard shortcuts

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