migrationartifact

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package migrationartifact owns atomic, immutable migration artifact files.

Index

Constants

View Source
const Extension = ".ridu.json"

Extension distinguishes Ridu artifacts from arbitrary JSON.

Variables

View Source
var (
	// ErrSchemaCurrent reports that a new migration would record nothing:
	// the schema is the one the latest migration records.
	ErrSchemaCurrent = errors.New("schema is current")
	// ErrOnlyAdminChanges reports that the schema differs from the latest
	// migration only in admin settings, which history ignores.
	ErrOnlyAdminChanges = fmt.Errorf("%w; only admin settings changed, so no migration is needed", ErrSchemaCurrent)
)

Functions

func AdoptionEnd added in v0.9.0

func AdoptionEnd(files []File, applied int, blockingStep func(File) string, matches func(index int) (bool, error)) (int, error)

AdoptionEnd decides how much of a pending history a baseline may record as applied without running it, on a database that schema sync already brought forward. It returns the history length after adoption: the newest artifact whose resulting schema the database has, provided no artifact up to it has a step schema sync never runs. Later artifacts stay pending for ridu migrate up.

matches reports whether the database's physical schema equals the schema after files[index]; blockingStep names a step that only a migration runner performs, or returns "" when every step is physical.

func LatestManifest

func LatestManifest(directory string) (schema.Manifest, bool, error)

LatestManifest returns the desired schema committed by the newest artifact.

Types

type File

type File struct {
	Path     string
	Name     string
	Digest   string
	Artifact migration.Artifact
}

File contains one parsed immutable migration and its filesystem identity.

func Create

func Create(directory, name string, artifact migration.Artifact, now time.Time) (File, error)

Create atomically creates one migration artifact and never overwrites an existing filename.

func ReadAll

func ReadAll(directory string) ([]File, error)

ReadAll parses, validates, and returns artifacts in lexical execution order.

func RequireCurrentHistory

func RequireCurrentHistory(directory string, executable schema.Manifest) ([]File, error)

RequireCurrentHistory proves that a deployable executable manifest is the exact head of a non-empty, immutable artifact history. An empty history is a valid input only to migration creation; release checks and database commands must fail closed until the initial artifact has been created and committed.

func RequireCurrentHistoryForPlanner

func RequireCurrentHistoryForPlanner(directory string, executable schema.Manifest, plannerName string) ([]File, error)

RequireCurrentHistoryForPlanner additionally proves that every immutable artifact belongs to the planner family selected by the project database. Adapter runners retain ownership of planner-version and exact-plan checks.

Jump to

Keyboard shortcuts

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