pgdelta

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDeclarative

func ApplyDeclarative(ctx context.Context, config pgconn.Config, fsys afero.Fs) error

ApplyDeclarative applies files from supabase/declarative to the target database using pg-delta's declarative apply engine.

This is intentionally separate from migration apply so declarative workflows can evolve independently from timestamped migration execution.

Types

type ApplyDiagnosis

type ApplyDiagnosis struct {
	Code         string                  `json:"code,omitempty"`
	Message      string                  `json:"message,omitempty"`
	StatementID  *ApplyStatementLocation `json:"statementId,omitempty"`
	SuggestedFix string                  `json:"suggestedFix,omitempty"`
}

ApplyDiagnosis mirrors pg-topo's Diagnostic entries: static-analysis warnings that are surfaced alongside the apply result but don't cause failure on their own. Shape must stay in sync with the pg-topo package.

UnmarshalJSON is implemented defensively so new or changed fields in pg-topo's Diagnostic do not break the whole apply result parse. Losing a diagnostic here would also swallow validationErrors and stuckStatements, leaving the user with a useless "failed to parse pg-delta apply output" message instead of the actual SQL error.

func (*ApplyDiagnosis) UnmarshalJSON

func (d *ApplyDiagnosis) UnmarshalJSON(data []byte) error

type ApplyIssue

type ApplyIssue struct {
	Statement         *ApplyStatement `json:"statement,omitempty"`
	Code              string          `json:"code,omitempty"`
	Message           string          `json:"message,omitempty"`
	IsDependencyError bool            `json:"isDependencyError,omitempty"`
	Position          int             `json:"position,omitempty"`
	Detail            string          `json:"detail,omitempty"`
	Hint              string          `json:"hint,omitempty"`
}

ApplyIssue models a pg-delta apply error or stuck statement.

pg-delta may emit either a plain string or a structured object, so unmarshal needs to gracefully handle both forms.

func (*ApplyIssue) UnmarshalJSON

func (i *ApplyIssue) UnmarshalJSON(data []byte) error

type ApplyResult

type ApplyResult struct {
	Status          string       `json:"status"`
	TotalStatements int          `json:"totalStatements"`
	TotalRounds     int          `json:"totalRounds"`
	TotalApplied    int          `json:"totalApplied"`
	TotalSkipped    int          `json:"totalSkipped"`
	Errors          []ApplyIssue `json:"errors"`
	StuckStatements []ApplyIssue `json:"stuckStatements"`
	// ValidationErrors captures failures from pg-delta's final
	// check_function_bodies=on pass. They are reported even when all
	// statements applied cleanly, so must be surfaced explicitly.
	ValidationErrors []ApplyIssue     `json:"validationErrors,omitempty"`
	Diagnostics      []ApplyDiagnosis `json:"diagnostics,omitempty"`
}

ApplyResult models the JSON payload emitted by pgdelta_declarative_apply.ts.

The fields are surfaced to provide concise CLI feedback after apply runs.

type ApplyStatement

type ApplyStatement struct {
	ID             string `json:"id"`
	SQL            string `json:"sql"`
	StatementClass string `json:"statementClass"`
}

type ApplyStatementLocation

type ApplyStatementLocation struct {
	FilePath       string `json:"filePath,omitempty"`
	StatementIndex int    `json:"statementIndex,omitempty"`
	SourceOffset   int    `json:"sourceOffset,omitempty"`
}

ApplyStatementLocation matches pg-topo's StatementId shape.

Jump to

Keyboard shortcuts

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