Documentation ¶
Overview ¶
Package schema provides functionality for modeling SQL constructs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct { Name string `json:"name"` Table *Table `json:"-"` Kind kind.Kind `json:"kind"` NotNull bool `json:"not_null"` HasDefault bool `json:"has_default"` // Size typically applies to text fields, e.g. VARCHAR(255). Size int `json:"size"` Unique bool `json:"unique"` ForeignKey *FKConstraint `json:"foreign_key,omitempty"` }
Column models a table column definition.
type FKConstraint ¶
type FKConstraint struct { // RefTable is the name of the referenced parent table. RefTable string `json:"ref_table"` // RefCol is the name of the referenced col in the parent table. RefCol string `json:"ref_col"` // OnDelete is one of CASCADE or SET_NULL, defaults to CASCADE. OnDelete string `json:"on_delete"` // OnUpdate is one of CASCADE or SET_NULL, defaults to CASCADE. OnUpdate string `json:"on_update"` }
FKConstraint models a foreign key constraint.
func (*FKConstraint) Equal ¶ added in v0.48.2
func (fk *FKConstraint) Equal(b *FKConstraint) bool
type Table ¶
type Table struct { // Name is the table name. Name string `json:"name"` // PKColName is the name of the primary key column, or empty. // // REVISIT: this construct does not allow for composite PK. PKColName string `json:"primary_key,omitempty"` // AutoIncrement, if true, indicates that a PK column // should autoincrement. // // REVISIT: this construct does not allow for composite PK. AutoIncrement bool `json:"auto_increment"` // Cols is the table's column definitions. Cols []*Column `json:"cols"` }
Table models a database table definition.
func (*Table) ColsByName ¶
ColsByName returns the ColDefs for each named column, or an error if any column is not matched.
Click to show internal directories.
Click to hide internal directories.