Help us shape the future of Go! Take the 2026 Go Developer Survey

changeset

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package changeset names atlas schema changes as selectable, typed migration changes and filters a diff down to a reviewed selection before planning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect struct {
	// Name prefixes errors, e.g. "sqlserver".
	Name string
	// DefaultSchema names objects whose atlas schema is unset (SQLite: main).
	DefaultSchema string
	// Object names a dialect-specific schema object; ok is false for an unknown one.
	Object func(schema.Object) (kind string, name migrate.Name, ok bool)
	// Destructive reports whether a described change may lose data, and why.
	Destructive func(schema.Change) (bool, string)
	// Rebuilds reports whether a table member change forces the whole table to
	// be rebuilt from its desired definition, which applies every sibling change.
	Rebuilds func(schema.Change) bool
}

Dialect supplies the parts of a change description that differ per backend.

type Set

type Set struct {
	Changes []migrate.Change
	// contains filtered or unexported fields
}

Set is the described diff: every selectable change in diff order, the atlas change each came from, and the table member changes per table.

func Describe

func Describe(diff []schema.Change, d Dialect) (*Set, error)

Describe names every change of a diff, recursing into table modifications, and records which other changes each one requires.

func (*Set) Change

func (s *Set) Change(id string) (migrate.Change, bool)

Change returns the described change with the given ID.

func (*Set) IDs

func (s *Set) IDs() []string

IDs lists every change ID in diff order.

func (*Set) Lookup

func (s *Set) Lookup(source schema.Change) ([]string, error)

Lookup returns the change IDs a planned statement implements. Planners synthesize sources for table rebuilds and their recreated indexes; those resolve to the table's member changes.

func (*Set) Require

func (s *Set) Require(id string, required ...string)

Require records that selecting id needs every one of required selected too.

func (*Set) Select

func (s *Set) Select(diff []schema.Change, selection []string) ([]schema.Change, error)

Select filters a diff to the selected change IDs, keeping a table modification with only its selected members. An empty selection keeps the whole diff. An unknown ID, or a selected change whose requirement is not selected, fails.

Jump to

Keyboard shortcuts

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