Documentation
¶
Overview ¶
Package diff provides schema comparison and migration generation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply compares the database against a schema directory and applies the resulting changes. Backup and migration run on a single connection inside one transaction.
func GenerateSQL ¶
GenerateSQL generates a complete migration script.
func HasDestructive ¶
HasDestructive returns true if any changes are destructive.
Types ¶
type ApplyOptions ¶
type ApplyOptions struct {
DryRun bool
SkipDestructive bool
BackupPath string // Path to create backup (empty = no backup)
}
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 ¶
Compare compares a database against a schema directory and returns changes. If SetBaseFS was called, reads from the embedded filesystem instead.
func CompareDatabases ¶
CompareDatabases compares two databases.
type ChangeType ¶
type ChangeType string
ChangeType represents the type of schema change.
const ( CreateTable ChangeType = "CREATE_TABLE" DropTable ChangeType = "DROP_TABLE" RenameTable ChangeType = "RENAME_TABLE" AddColumn ChangeType = "ADD_COLUMN" RenameColumn ChangeType = "RENAME_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" )