scripts

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package scripts owns migration source identity, dependencies and consumed fingerprints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Digest

func Digest(fields ...string) string

func InputHash

func InputHash(inputs map[string]string) string

func QuoteName

func QuoteName(name string) (string, error)

func SourceHash

func SourceHash(content string) string

Types

type Analysis

type Analysis struct {
	Calls              []string                  `json:"calls"`
	Builtins           []sqlglot.BuiltinFunction `json:"builtins,omitempty"`
	Blocked            []string                  `json:"blocked,omitempty"`
	Unresolved         []string                  `json:"unresolved,omitempty"`
	TransactionControl bool                      `json:"transactionControl,omitempty"`
}

func Analyze

func Analyze(opts AnalysisOptions) Analysis

Analyze visits executable expressions, leaving stored module bodies for catalog analysis.

type AnalysisOptions

type AnalysisOptions struct {
	SQL           string
	InvokedModule bool
}

type Dependency

type Dependency struct {
	Kind string `json:"kind"`
	Name string `json:"name"`
}

type LoadOptions

type LoadOptions struct {
	FS   fs.FS
	Dir  string
	Skip []string
}

type Observation

type Observation struct {
	Kind  string `json:"kind"`
	Hash  string `json:"hash"`
	Error string `json:"error,omitempty"`
}

type Pending

type Pending struct {
	Script   Script   `json:"script"`
	State    State    `json:"state"`
	Selected bool     `json:"selected"`
	Reasons  []string `json:"reasons,omitempty"`
	Blocked  []string `json:"blocked,omitempty"`
}

type Phase

type Phase string
const (
	Pre     Phase = "pre"
	Post    Phase = "post"
	Version       = 2
)

type Plan

type Plan struct {
	Target  string    `json:"target"`
	Phase   Phase     `json:"phase"`
	Hash    string    `json:"hash"`
	Scripts []Pending `json:"scripts"`
}

func Build

func Build(opts PlanOptions) (Plan, error)

type PlanOptions

type PlanOptions struct {
	Target       string
	Phase        Phase
	Scripts      []Script
	Recorded     map[string]State
	Observations map[string]map[string]Observation
}

type Scalar

type Scalar struct {
	Type      string `json:"type"`
	Length    int64  `json:"length"`
	Precision int64  `json:"precision"`
	Scale     int64  `json:"scale"`
	Null      bool   `json:"null"`
	Value     string `json:"value"`
}

func (Scalar) Fingerprint

func (s Scalar) Fingerprint(invocation string) (string, error)

type Script

type Script struct {
	ID                   string       `json:"id"`
	Path                 string       `json:"path"`
	Name                 string       `json:"name"`
	SQL                  string       `json:"sql"`
	Phase                Phase        `json:"phase"`
	HeaderPhase          Phase        `json:"-"`
	Always               bool         `json:"always,omitempty"`
	NonTransactional     bool         `json:"nonTransactional,omitempty"`
	DependsOn            []string     `json:"dependsOn,omitempty"`
	Dependencies         []Dependency `json:"dependencies,omitempty"`
	ExplicitDependencies bool         `json:"explicitDependencies,omitempty"`
	ContextPolicy        string       `json:"contextPolicy,omitempty"`
}

func Load

func Load(opts LoadOptions) ([]Script, error)

func Ordered

func Ordered(items []Script) ([]Script, error)

func Parse

func Parse(name, content string) (Script, error)

type State

type State struct {
	Version      int               `json:"version"`
	SourceHash   string            `json:"sourceHash"`
	PolicyHash   string            `json:"policyHash"`
	Hash         string            `json:"hash"`
	Inputs       map[string]string `json:"inputs"`
	Outcome      string            `json:"outcome,omitempty"`
	EvidenceHash string            `json:"evidenceHash,omitempty"`
	Provenance   string            `json:"provenance,omitempty"`
	LastSuccess  *State            `json:"lastSuccess,omitempty"`
}

Directories

Path Synopsis
Package sqlserver observes and executes dependency-aware scripts on SQL Server.
Package sqlserver observes and executes dependency-aware scripts on SQL Server.
sqlservertest
Package sqlservertest provisions private, temporary SQL Server fixtures for Ginkgo suites.
Package sqlservertest provisions private, temporary SQL Server fixtures for Ginkgo suites.

Jump to

Keyboard shortcuts

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