plan

package
v1.7.0 Latest Latest
Warning

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

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

README

Plan Command

Running Tests

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

# Specific plan tests
go test -v ./cmd/plan/ -run "TestPlanCommand_FileToDatabase"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PlanCmd = &cobra.Command{
	Use:          "plan",
	Short:        "Generate migration plan for a specific schema",
	Long:         "Generate a migration plan to apply a desired schema state to a target database schema. Compares the desired state (from --file) with the current state of a specific schema (specified by --schema, defaults to 'public').",
	RunE:         runPlan,
	SilenceUsage: true,
	PreRunE:      util.PreRunEWithEnvVarsAndConnection(&planDB, &planUser, &planHost, &planPort),
}

Functions

func CreateDesiredStateProvider

func CreateDesiredStateProvider(config *PlanConfig) (postgres.DesiredStateProvider, error)

CreateDesiredStateProvider creates either an embedded PostgreSQL instance or connects to an external database for validating the desired state schema. The caller is responsible for calling Stop() on the returned provider.

func CreateEmbeddedPostgresForPlan

func CreateEmbeddedPostgresForPlan(config *PlanConfig, pgVersion postgres.PostgresVersion) (*postgres.EmbeddedPostgres, error)

CreateEmbeddedPostgresForPlan creates a temporary embedded PostgreSQL instance for validating the desired state schema. The instance should be stopped by the caller.

func GeneratePlan

func GeneratePlan(config *PlanConfig, provider postgres.DesiredStateProvider) (*plan.Plan, error)

GeneratePlan generates a migration plan from configuration. The caller must provide a non-nil provider instance for validating the desired state schema. The caller is responsible for managing the provider lifecycle (creation and cleanup).

func ResetFlags

func ResetFlags()

ResetFlags resets all global flag variables to their default values for testing

Types

type PlanConfig

type PlanConfig struct {
	Host            string
	Port            int
	DB              string
	User            string
	Password        string
	Schema          string
	File            string
	ApplicationName string
	// Plan database configuration (optional - for external database)
	PlanDBHost     string
	PlanDBPort     int
	PlanDBDatabase string
	PlanDBUser     string
	PlanDBPassword string
}

PlanConfig holds configuration for plan generation

Jump to

Keyboard shortcuts

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