sqlspec

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MightHeredoc added in v0.26.0

func MightHeredoc(s string) string

MightHeredoc returns the string as an indented heredoc if it has multiple lines.

Types

type Check added in v0.3.0

type Check struct {
	Name string `spec:",name"`
	Expr string `spec:"expr"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

Check holds a specification for a check constraint on a table.

type Column

type Column struct {
	Name string          `spec:",name"`
	Null bool            `spec:"null"`
	Type *schemahcl.Type `spec:"type"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

Column holds a specification for a column in an SQL table.

type ForeignKey

type ForeignKey struct {
	Symbol     string           `spec:",name"`
	Columns    []*schemahcl.Ref `spec:"columns"`
	RefColumns []*schemahcl.Ref `spec:"ref_columns"`
	OnUpdate   *schemahcl.Ref   `spec:"on_update"`
	OnDelete   *schemahcl.Ref   `spec:"on_delete"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

ForeignKey holds a specification for the Foreign key of a table.

type Index

type Index struct {
	Name    string           `spec:",name"`
	Unique  bool             `spec:"unique,omitempty"`
	Parts   []*IndexPart     `spec:"on"`
	Columns []*schemahcl.Ref `spec:"columns"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

Index holds a specification for the index key of a table.

type IndexPart added in v0.3.2

type IndexPart struct {
	Desc   bool           `spec:"desc,omitempty"`
	Column *schemahcl.Ref `spec:"column"`
	Expr   string         `spec:"expr,omitempty"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

IndexPart holds a specification for the index key part.

type PrimaryKey

type PrimaryKey struct {
	Name    string           `spec:",name"` // Optional name.
	Parts   []*IndexPart     `spec:"on"`
	Columns []*schemahcl.Ref `spec:"columns"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

PrimaryKey holds a specification for the primary key of a table.

type Schema

type Schema struct {
	Name string `spec:"name,name"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

Schema holds a specification for a Schema.

type Sequence added in v0.20.0

type Sequence struct {
	Name      string         `spec:",name"`
	Qualifier string         `spec:",qualifier"`
	Schema    *schemahcl.Ref `spec:"schema"`
	// Type, Start, Increment, Min, Max, Cache, Cycle
	// are optionally added to the sequence definition.
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

Sequence holds a specification for a Sequence.

func (*Sequence) Label added in v0.20.0

func (s *Sequence) Label() string

Label returns the defaults label used for the sequence resource.

func (*Sequence) QualifierLabel added in v0.20.0

func (s *Sequence) QualifierLabel() string

QualifierLabel returns the qualifier label used for the sequence resource, if any.

func (*Sequence) SchemaRef added in v0.20.0

func (s *Sequence) SchemaRef() *schemahcl.Ref

SchemaRef returns the schema reference for the sequence.

func (*Sequence) SetQualifier added in v0.20.0

func (s *Sequence) SetQualifier(q string)

SetQualifier sets the qualifier label used for the sequence resource.

type Table

type Table struct {
	Name        string         `spec:",name"`
	Qualifier   string         `spec:",qualifier"`
	Schema      *schemahcl.Ref `spec:"schema"`
	Columns     []*Column      `spec:"column"`
	PrimaryKey  *PrimaryKey    `spec:"primary_key"`
	ForeignKeys []*ForeignKey  `spec:"foreign_key"`
	Indexes     []*Index       `spec:"index"`
	Checks      []*Check       `spec:"check"`
	schemahcl.DefaultExtension
	Range *hcl.Range `spec:",range"`
}

Table holds a specification for an SQL table.

func (*Table) Label added in v0.13.2

func (t *Table) Label() string

Label returns the defaults label used for the table resource.

func (*Table) QualifierLabel added in v0.13.2

func (t *Table) QualifierLabel() string

QualifierLabel returns the qualifier label used for the table resource, if any.

func (*Table) SchemaRef added in v0.13.2

func (t *Table) SchemaRef() *schemahcl.Ref

SchemaRef returns the schema reference for the table.

func (*Table) SetQualifier added in v0.13.2

func (t *Table) SetQualifier(q string)

SetQualifier sets the qualifier label used for the table resource.

Jump to

Keyboard shortcuts

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