apply

package
v1.7.1 Latest Latest
Warning

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

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

README

Apply Command

Running Tests

# All apply tests
go test -v ./cmd/apply/

# Specific apply tests
go test -v ./cmd/apply/ -run "TestApplyCommand_TransactionRollback"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApplyCmd = &cobra.Command{
	Use:          "apply",
	Short:        "Apply migration plan to update a database schema",
	Long:         "Apply a migration plan to update a database schema. Either provide a desired state file (--file) to generate and apply a plan, or provide a pre-generated plan file (--plan) to execute directly.",
	RunE:         RunApply,
	SilenceUsage: true,
	PreRunE:      util.PreRunEWithEnvVarsAndConnectionAndApp(&applyDB, &applyUser, &applyHost, &applyPort, &applyApplicationName),
}

Functions

func ApplyMigration

func ApplyMigration(config *ApplyConfig, provider postgres.DesiredStateProvider) error

ApplyMigration applies a migration plan to update a database schema. The caller must provide either: - A pre-generated plan in config.Plan, OR - A desired state file in config.File with a non-nil provider instance

If config.File is provided, provider is used to generate the plan. The caller is responsible for managing the provider lifecycle (creation and cleanup).

func RunApply

func RunApply(cmd *cobra.Command, args []string) error

RunApply executes the apply command logic. Exported for testing.

Types

type ApplyConfig

type ApplyConfig struct {
	Host            string
	Port            int
	DB              string
	User            string
	Password        string
	Schema          string
	File            string     // Desired state file (optional, used with embeddedPG)
	Plan            *plan.Plan // Pre-generated plan (optional, alternative to File)
	AutoApprove     bool
	NoColor         bool
	Quiet           bool // Suppress plan display and progress messages (useful for tests)
	LockTimeout     string
	ApplicationName string
}

ApplyConfig holds configuration for apply execution

Jump to

Keyboard shortcuts

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