Help us shape the future of Go! Take the 2026 Go Developer Survey

snapshot

package
v1.0.6 Latest Latest
Warning

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

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

README

Complete migration snapshots

snapshot.Inspect(ctx, db, snapshot.Options{Schemas: []string{"dbo"}}) reads full SQL Server migration definitions without the row or definition limits used by the interactive explorer. Schemas are explicit. The connection must have database VIEW DEFINITION permission so hidden metadata cannot look like absent objects.

Inspection reuses the shared SQL Server catalogue reader for tables, columns, indexes, keys, checks and routines. It also reads column collations, view and trigger definitions, trigger state and module dependencies. The result uses sqlglot's native migration model; this package does not generate or execute migrations.

The current contract targets SQL Server 2016 or newer, including databases at compatibility level 100. Unsupported computed or user-defined columns, storage settings, indexed views, disabled or untrusted constraints, unsupported module session settings, and external or unresolved dependencies cause explicit errors. This prevents a partial catalogue from becoming a destructive desired state.

Default, check or column expressions that depend on other database objects are also blocked: the native table model does not yet carry those dependencies for ordering and selection validation.

Trigger schemas come from sys.objects, while parent and disabled state come from sys.triggers.

go test ./inspect/sql/snapshot -count=1

The tests separate pure catalogue projection from database-driver boundary checks. Live SQL Server execution remains a separate integration gate.

Documentation

Overview

Package snapshot inspects complete SQL Server schemas for migration planning. Query bounds used by the interactive explorer never apply to these snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct{ Schemas []string }

type Querier

type Querier interface {
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
}

Querier is implemented by a database, pinned connection or transaction.

type Result

type Result struct {
	Schema  migrate.Schema
	Schemas []string
}

func Inspect

func Inspect(ctx context.Context, db Querier, options Options) (Result, error)

Jump to

Keyboard shortcuts

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