package sqlspec
import "ariga.io/atlas/sql/sqlspec"
Index ¶
- func MightHeredoc(s string) string
- type Check
- type Column
- type ForeignKey
- type Func
- func (f *Func) Label() string
- func (f *Func) QualifierLabel() string
- func (f *Func) SchemaRef() *schemahcl.Ref
- func (f *Func) SetQualifier(q string)
- type FuncArg
- type Index
- type IndexPart
- type PrimaryKey
- type Schema
- type Sequence
- func (s *Sequence) Label() string
- func (s *Sequence) QualifierLabel() string
- func (s *Sequence) SchemaRef() *schemahcl.Ref
- func (s *Sequence) SetQualifier(q string)
- type Table
- func (t *Table) Label() string
- func (t *Table) QualifierLabel() string
- func (t *Table) SchemaRef() *schemahcl.Ref
- func (t *Table) SetQualifier(q string)
- type Trigger
- type View
Functions ¶
func MightHeredoc ¶
MightHeredoc returns the string as an indented heredoc if it has multiple lines.
Types ¶
type Check ¶
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 Func ¶
type Func struct { Name string `spec:",name"` Qualifier string `spec:",qualifier"` Schema *schemahcl.Ref `spec:"schema"` Args []*FuncArg `spec:"arg"` Lang cty.Value `spec:"lang"` // The definition and the return type are appended as additional // attribute by the spec creator to marshal it after the arguments. schemahcl.DefaultExtension Range *hcl.Range `spec:",range"` }
Func holds the specification for a function.
func (*Func) Label ¶
Label returns the defaults label used for the function resource.
func (*Func) QualifierLabel ¶
QualifierLabel returns the qualifier label used for the function resource, if any.
func (*Func) SchemaRef ¶
SchemaRef returns the schema reference for the function.
func (*Func) SetQualifier ¶
SetQualifier sets the qualifier label used for the function resource.
type FuncArg ¶
type FuncArg struct { Name string `spec:",name"` Type *schemahcl.Type `spec:"type"` Default cty.Value `spec:"default"` // Optional attributes such as mode are added by the driver, // as their definition can be either a string or an enum (ref). schemahcl.DefaultExtension Range *hcl.Range `spec:",range"` }
FuncArg holds the specification for a function argument.
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 ¶
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 ¶
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 ¶
Label returns the defaults label used for the sequence resource.
func (*Sequence) QualifierLabel ¶
QualifierLabel returns the qualifier label used for the sequence resource, if any.
func (*Sequence) SchemaRef ¶
SchemaRef returns the schema reference for the sequence.
func (*Sequence) SetQualifier ¶
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 ¶
Label returns the defaults label used for the table resource.
func (*Table) QualifierLabel ¶
QualifierLabel returns the qualifier label used for the table resource, if any.
func (*Table) SchemaRef ¶
SchemaRef returns the schema reference for the table.
func (*Table) SetQualifier ¶
SetQualifier sets the qualifier label used for the table resource.
type Trigger ¶
type Trigger struct { Name string `spec:",name"` On *schemahcl.Ref `spec:"on"` // A table or a view. // Attributes and blocks are different for each driver. schemahcl.DefaultExtension Range *hcl.Range `spec:",range"` }
Trigger holds the specification for a trigger.
type View ¶
type View struct { Name string `spec:",name"` Qualifier string `spec:",qualifier"` Schema *schemahcl.Ref `spec:"schema"` Columns []*Column `spec:"column"` // Indexes on (materialized) views are supported // by some databases, like PostgreSQL. Indexes []*Index `spec:"index"` // The definition is appended as additional attribute // by the spec creator to marshal it after the columns. schemahcl.DefaultExtension Range *hcl.Range `spec:",range"` }
View holds a specification for an SQL view.
func (*View) Label ¶
Label returns the defaults label used for the view resource.
func (*View) QualifierLabel ¶
QualifierLabel returns the qualifier label used for the view resource, if any.
func (*View) SchemaRef ¶
SchemaRef returns the schema reference for the view.
func (*View) SetQualifier ¶
SetQualifier sets the qualifier label used for the view resource.
Source Files ¶
sqlspec.go
- Version
- v0.32.0 (latest)
- Published
- Mar 10, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 1 month ago –
Tools for package owners.