Versions in this module Expand all Collapse all v0 v0.1.0 Aug 19, 2026 Changes in this version + var ErrCommentLoss = errors.New("input contains comments, which formatting would discard") + var ErrConcurrentIndex = errors.New("CONCURRENTLY cannot be used in a desired schema") + var ErrDisallowedStatement = errors.New("statement kind not allowed in a desired schema") + var ErrEmptyDesired = errors.New("desired schema contains no statements") + var ErrForeignKey = errors.New("foreign keys are not supported in a desired schema") + var ErrMultipleCreateTables = errors.New("desired schema must contain exactly one CREATE TABLE") + var ErrNoCreateTable = errors.New("desired schema must contain a CREATE TABLE") + var ErrNotOneStatement = errors.New("input must contain exactly one SQL statement") + var ErrNotRewritable = errors.New("statement has no concurrent form") + var ErrNotValidNotApplicable = errors.New("statement cannot take NOT VALID") + var ErrQualifiedName = errors.New("desired schema statements must use unqualified names") + var ErrWrongIndexTarget = errors.New("index must target the desired table") + func AddNotValid(sql string) (rewritten, constraint string, err error) + func Canonical(sql string) (string, error) + func CheckNoComments(sql string) error + func Concurrently(sql string) (string, error) + func Qualify(sql, schema string) (string, error) + type ConstraintKind int + const ConstraintCheck + const ConstraintForeignKey + const ConstraintNotNull + const ConstraintPrimaryKey + const ConstraintUnique + const ConstraintUnrecognized + type DefaultKind int + const DefaultConstant + const DefaultExpression + const DefaultNone + type DesiredSchema struct + func ParseDesired(sql string) (DesiredSchema, error) + func (ds DesiredSchema) Statements() []Statement + func (ds DesiredSchema) Table() string + type Kind int + const KindAlterTable + const KindCreateIndex + const KindCreateTable + const KindDropIndex + const KindOther + const KindReindex + func (k Kind) String() string + type Op struct + Column string + Columns []string + Concurrent bool + Constraint ConstraintKind + Default DefaultKind + GeneratedStored bool + HasUsing bool + IfNotExists bool + InlineConstraints []ConstraintKind + Kind OpKind + Name string + NewType string + NewTypeMods []int32 + NotValid bool + PartitionOf bool + Unique bool + UsingIndex bool + func ParseOps(sql string) ([]Op, error) + func (o Op) Describe() string + type OpKind int + const OpAddColumn + const OpAddConstraint + const OpAlterColumnType + const OpAttachPartition + const OpCreateIndex + const OpCreateTable + const OpDetachPartition + const OpDropColumn + const OpDropConstraint + const OpDropDefault + const OpDropIndex + const OpDropNotNull + const OpReindex + const OpRenameColumn + const OpRenameIndex + const OpRenameTable + const OpSetColumnOptions + const OpSetDefault + const OpSetNotNull + const OpSetRelOptions + const OpSetSchema + const OpSetTablespace + const OpUnrecognized + const OpValidateConstraint + type SourceStatement struct + Column int + Line int + SQL string + func Split(sql string) ([]SourceStatement, error) + type Statement struct + func ParseOne(sql string) (Statement, error) + func (s Statement) BuildsIndex() bool + func (s Statement) Concurrent() bool + func (s Statement) Kind() Kind + func (s Statement) SQL() string + func (s Statement) Schema() string + func (s Statement) Table() string