schemadiff

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package schemadiff compares canonical manifests for migration intent that cannot be inferred safely from a database schema alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadManifest

func ReadManifest(path string) (schema.Manifest, bool, error)

ReadManifest reads one optional canonical manifest file.

Types

type FieldPair

type FieldPair struct {
	Before schema.Field
	After  schema.Field
}

FieldPair relates the same physical field before and after a collection rename.

type RenameCandidate

type RenameCandidate struct {
	Kind             RenameKind
	BeforeCollection schema.Collection
	AfterCollection  schema.Collection
	BeforeField      *schema.Field
	AfterField       *schema.Field
	Fields           []FieldPair
}

RenameCandidate is an unambiguous structural match that still requires explicit human confirmation before migration SQL may preserve its data.

func RenameCandidates

func RenameCandidates(before, after schema.Manifest) []RenameCandidate

RenameCandidates returns only one-to-one, shape-compatible collection and recursively nested field matches. Ambiguous matches are deliberately omitted.

func RenameCandidatesWithCollectionMapping

func RenameCandidatesWithCollectionMapping(before, after schema.Manifest, collectionMapping map[schema.StableID]schema.StableID) []RenameCandidate

RenameCandidatesWithCollectionMapping normalizes references in the before manifest through simultaneously confirmed collection identities. It is used to replay immutable multi-rename artifacts where an owner and one of its relationship or upload targets move in the same transaction. Every mapped collection must still match its own unique structural rename candidate.

type RenameKind

type RenameKind string

RenameKind identifies the kind of schema address that may have changed.

const (
	RenameCollection RenameKind = "collection"
	RenameField      RenameKind = "field"
)

Jump to

Keyboard shortcuts

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