sqlserver

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlserver is the database half of the SQL Server dialect of the schema engine: it reads capabilities, schemas and the live dependents of columns, and runs a unit on one connection. Diffing, lowering and preconditions are the pure planner it embeds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportHCL

func ExportHCL(ctx context.Context, q engine.Querier, opts ExportOptions) ([]planner.HCLFile, error)

ExportHCL reads the tables of one schema and writes them as SQL Server HCL that the bundle evaluator reads back to the same tables (see planner.ExportHCL). Whatever the inspector could not read of a selected table (a refused table or member) fails the export, unless HCL.OmitUnsupported turns it into a comment line at the top of the output.

Types

type Dialect

type Dialect struct {
	planner.Planner
}

Dialect is registered as "sqlserver".

func (Dialect) Capabilities

func (d Dialect) Capabilities(ctx context.Context, q engine.Querier) (engine.Capabilities, error)

Capabilities probes the database. Feature keys are the BackendCapability values, so the planner's FeatureTryConvert is the key of the same name. With q == nil it answers the planner's static, offline capabilities.

func (Dialect) Dependents

func (d Dialect) Dependents(ctx context.Context, q engine.Querier, current migrate.Schema, columns []engine.ColumnRef) ([]engine.Dependent, error)

Dependents lists what depends on columns. Without a database it derives the answer from current, as the pure planner does. With one it reads the catalog: everything SQL Server refuses to alter a column under, with the definition that re-creates it exactly, or a Refusal for what it cannot reproduce.

func (Dialect) Exec

Exec runs one statement of a plan in a nested batch.

func (Dialect) Inspect

func (Dialect) Inspect(ctx context.Context, q engine.Querier, scope engine.Scope) (engine.Inspection, error)

Inspect reads the schema. Complete mode reads every object of scope.Schemas. Declared mode reads exactly the scope's objects that exist, with the catalog narrowed to their names. What the native model cannot hold comes back as a refusal instead of failing the inspection, so an object nobody touches never blocks a plan.

func (Dialect) Open

Open starts one unit on its connection: the transaction when the unit has one, the application lock, SET LOCK_TIMEOUT and SET XACT_ABORT ON. A zero lock timeout means no waiting, for the application lock and for blocked statements. Finish ends the transaction, releases the lock and puts the connection's settings back, so the pooled connection is clean.

func (Dialect) Reconcile

func (Dialect) Reconcile(_ context.Context, _ engine.Querier, current, desired migrate.Schema) (migrate.Schema, error)

Reconcile rewrites desired so that what it leaves unset inherits the live value and what the server compares as equal is spelled like the live value. It touches nothing else: a real difference stays one. The rules:

  • a column of a character type with no collation takes the live column's collation, and a collation that differs only in case takes the live spelling.

func (Dialect) SameDependent

func (Dialect) SameDependent(before, after engine.Dependent) (bool, error)

SameDependent judges a rebuilt dependent identical when what re-creates it is equal. Every definition is normalised where it is read, so a strict comparison is enough.

type ExportOptions

type ExportOptions struct {
	Schema string
	// Tables are the tables to export; empty exports every table of the schema.
	Tables []string
	// HCL configures the writer. DatabaseCollation is read from the database.
	HCL planner.HCLOptions
}

ExportOptions select what ExportHCL reads and how it writes it.

Jump to

Keyboard shortcuts

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