diff

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package diff provides schema comparison and migration generation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(dbPath, schemaDir string, opts ApplyOptions) error

Apply applies schema changes to a database

func GenerateSQL

func GenerateSQL(changes []Change) string

GenerateSQL generates a complete migration script

func HasDestructive

func HasDestructive(changes []Change) bool

HasDestructive returns true if any changes are destructive

func ShowChanges

func ShowChanges(changes []Change)

ShowChanges prints a list of changes

Types

type ApplyOptions

type ApplyOptions struct {
	DryRun          bool
	SkipDestructive bool
	Backup          bool
	ShowChanges     bool
}

ApplyOptions configures how changes are applied

type Change

type Change struct {
	Type        ChangeType
	Object      string   // Name of the object being changed
	Description string   // Human-readable description
	SQL         []string // SQL statements to apply
	Destructive bool     // Whether this change may lose data
}

Change represents a single schema change

func Compare

func Compare(dbPath, schemaDir string) ([]Change, error)

Compare compares a database against a schema directory and returns changes

func CompareDatabases

func CompareDatabases(fromDB, toDB string) ([]Change, error)

CompareDatabases compares two databases

func Diff

func Diff(from, to *schema.Database) []Change

Diff compares two schemas and returns the changes

type ChangeType

type ChangeType string

ChangeType represents the type of schema change

const (
	CreateTable   ChangeType = "CREATE_TABLE"
	DropTable     ChangeType = "DROP_TABLE"
	AddColumn     ChangeType = "ADD_COLUMN"
	RecreateTable ChangeType = "RECREATE_TABLE"
	CreateIndex   ChangeType = "CREATE_INDEX"
	DropIndex     ChangeType = "DROP_INDEX"
	CreateView    ChangeType = "CREATE_VIEW"
	DropView      ChangeType = "DROP_VIEW"
	CreateTrigger ChangeType = "CREATE_TRIGGER"
	DropTrigger   ChangeType = "DROP_TRIGGER"
)

Jump to

Keyboard shortcuts

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