Documentation ¶
Index ¶
- Constants
- Variables
- func Build(phrase string) *sqlx.Builder
- func FormatType(t schema.Type) (string, error)
- func MarshalSpec(v interface{}, marshaler schemaspec.Marshaler) ([]byte, error)
- func Open(db schema.ExecQuerier) (migrate.Driver, error)
- func ParseType(typ string) (schema.Type, error)
- type ArrayType
- type BitType
- type CType
- type CheckColumns
- type ConType
- type CurrencyType
- type Driver
- type Enum
- type Identity
- type IndexColumnProperty
- type IndexPredicate
- type IndexStorageParams
- type IndexType
- type NetworkType
- type NoInherit
- type Partition
- type PartitionPart
- type Sequence
- type SerialType
- type UUIDType
- type UserDefinedType
- type XMLType
Constants ¶
const ( TypeInt64 = "int64" TypeGeometry = "geometry" )
CockroachDB types that are not part of PostgreSQL.
const ( TypeBit = "bit" TypeBitVar = "bit varying" TypeBoolean = "boolean" TypeBool = "bool" // boolean. TypeBytea = "bytea" TypeCharacter = "character" TypeChar = "char" // character TypeCharVar = "character varying" TypeVarChar = "varchar" // character varying TypeText = "text" TypeSmallInt = "smallint" TypeInteger = "integer" TypeBigInt = "bigint" TypeInt = "int" // integer. TypeInt2 = "int2" // smallint. TypeInt4 = "int4" // integer. TypeInt8 = "int8" // bigint. TypeCIDR = "cidr" TypeInet = "inet" TypeMACAddr = "macaddr" TypeMACAddr8 = "macaddr8" TypeCircle = "circle" TypeLine = "line" TypeLseg = "lseg" TypeBox = "box" TypePath = "path" TypePolygon = "polygon" TypePoint = "point" TypeDate = "date" TypeTime = "time" // time without time zone TypeTimeTZ = "timetz" // time with time zone TypeTimeWTZ = "time with time zone" TypeTimeWOTZ = "time without time zone" TypeTimestamp = "timestamp" // timestamp without time zone TypeTimestampTZ = "timestamptz" TypeTimestampWTZ = "timestamp with time zone" TypeTimestampWOTZ = "timestamp without time zone" TypeDouble = "double precision" TypeReal = "real" TypeFloat8 = "float8" // double precision TypeFloat4 = "float4" // real TypeNumeric = "numeric" TypeDecimal = "decimal" // numeric TypeSmallSerial = "smallserial" // smallint with auto_increment. TypeSerial = "serial" // integer with auto_increment. TypeBigSerial = "bigserial" // bigint with auto_increment. TypeSerial2 = "serial2" // smallserial TypeSerial4 = "serial4" // serial TypeSerial8 = "serial8" // bigserial TypeArray = "array" TypeXML = "xml" TypeJSON = "json" TypeJSONB = "jsonb" TypeUUID = "uuid" TypeMoney = "money" TypeInterval = "interval" TypeUserDefined = "user-defined" )
Standard column types (and their aliases) as defined in PostgreSQL codebase/website.
const ( IndexTypeBTree = "BTREE" IndexTypeHash = "HASH" IndexTypeGIN = "GIN" IndexTypeGiST = "GIST" IndexTypeBRIN = "BRIN" )
List of supported index types.
const ( GeneratedTypeAlways = "ALWAYS" GeneratedTypeByDefault = "BY_DEFAULT" // BY DEFAULT. )
List of "GENERATED" types.
const ( PartitionTypeRange = "RANGE" PartitionTypeList = "LIST" PartitionTypeHash = "HASH" )
List of PARTITION KEY types.
Variables ¶
var ( // UnmarshalHCL unmarshals an Atlas HCL DDL document into v. UnmarshalHCL = schemaspec.UnmarshalerFunc(func(data []byte, v interface{}) error { return evalSpec(data, v, nil) }) // MarshalHCL marshals v into an Atlas HCL DDL document. MarshalHCL = schemaspec.MarshalerFunc(func(v interface{}) ([]byte, error) { return MarshalSpec(v, hclState) }) // EvalHCL implements the schemahcl.Evaluator interface. EvalHCL = schemahcl.EvalFunc(evalSpec) )
var TypeRegistry = schemahcl.NewRegistry( schemahcl.WithSpecFunc(typeSpec), schemahcl.WithParser(ParseType), schemahcl.WithSpecs( schemahcl.TypeSpec(TypeBit, schemahcl.WithAttributes(&schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64})), schemahcl.AliasTypeSpec("bit_varying", TypeBitVar, schemahcl.WithAttributes(&schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64})), schemahcl.TypeSpec(TypeVarChar, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("character_varying", TypeCharVar, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec(TypeChar, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(true))), schemahcl.TypeSpec(TypeCharacter, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(true))), schemahcl.TypeSpec(TypeInt2), schemahcl.TypeSpec(TypeInt4), schemahcl.TypeSpec(TypeInt8), schemahcl.TypeSpec(TypeInt), schemahcl.TypeSpec(TypeInteger), schemahcl.TypeSpec(TypeSmallInt), schemahcl.TypeSpec(TypeBigInt), schemahcl.TypeSpec(TypeText), schemahcl.TypeSpec(TypeBoolean), schemahcl.TypeSpec(TypeBool), schemahcl.TypeSpec(TypeBytea), schemahcl.TypeSpec(TypeCIDR), schemahcl.TypeSpec(TypeInet), schemahcl.TypeSpec(TypeMACAddr), schemahcl.TypeSpec(TypeMACAddr8), schemahcl.TypeSpec(TypeCircle), schemahcl.TypeSpec(TypeLine), schemahcl.TypeSpec(TypeLseg), schemahcl.TypeSpec(TypeBox), schemahcl.TypeSpec(TypePath), schemahcl.TypeSpec(TypePoint), schemahcl.TypeSpec(TypeDate), schemahcl.TypeSpec(TypeTime, schemahcl.WithAttributes(precisionTypeAttr()), formatTime()), schemahcl.TypeSpec(TypeTimeTZ, schemahcl.WithAttributes(precisionTypeAttr()), formatTime()), schemahcl.TypeSpec(TypeTimestampTZ, schemahcl.WithAttributes(precisionTypeAttr()), formatTime()), schemahcl.TypeSpec(TypeTimestamp, schemahcl.WithAttributes(precisionTypeAttr()), formatTime()), schemahcl.AliasTypeSpec("double_precision", TypeDouble), schemahcl.TypeSpec(TypeReal), schemahcl.TypeSpec(TypeFloat8), schemahcl.TypeSpec(TypeFloat4), schemahcl.TypeSpec(TypeNumeric), schemahcl.TypeSpec(TypeDecimal), schemahcl.TypeSpec(TypeSmallSerial), schemahcl.TypeSpec(TypeSerial), schemahcl.TypeSpec(TypeBigSerial), schemahcl.TypeSpec(TypeSerial2), schemahcl.TypeSpec(TypeSerial4), schemahcl.TypeSpec(TypeSerial8), schemahcl.TypeSpec(TypeXML), schemahcl.TypeSpec(TypeJSON), schemahcl.TypeSpec(TypeJSONB), schemahcl.TypeSpec(TypeUUID), schemahcl.TypeSpec(TypeMoney), schemahcl.TypeSpec("hstore"), schemahcl.TypeSpec("sql", schemahcl.WithAttributes(&schemaspec.TypeAttr{Name: "def", Required: true, Kind: reflect.String})), ), )
TypeRegistry contains the supported TypeSpecs for the Postgres driver.
Functions ¶
func FormatType ¶ added in v0.2.0
FormatType converts schema type to its column form in the database. An error is returned if the type cannot be recognized.
func MarshalSpec ¶
func MarshalSpec(v interface{}, marshaler schemaspec.Marshaler) ([]byte, error)
MarshalSpec marshals v into an Atlas DDL document using a schemaspec.Marshaler.
Types ¶
type ArrayType ¶
ArrayType defines an array type. https://www.postgresql.org/docs/current/arrays.html
type BitType ¶
BitType defines a bit type. https://www.postgresql.org/docs/current/datatype-bit.html
type CheckColumns ¶ added in v0.2.0
CheckColumns attribute hold the column named used by the CHECK constraints. This attribute is added on inspection for internal usage and has no meaning on migration.
type ConType ¶
ConType describes constraint type. https://www.postgresql.org/docs/current/catalog-pg-constraint.html
type CurrencyType ¶
A CurrencyType defines a currency type.
type Driver ¶
type Driver struct { schema.Differ schema.Inspector migrate.PlanApplier // contains filtered or unexported fields }
Driver represents a PostgreSQL driver for introspecting database schemas, generating diff between schema elements and apply migrations changes.
func (*Driver) Lock ¶ added in v0.3.8
func (d *Driver) Lock(ctx context.Context, name string, timeout time.Duration) (schema.UnlockFunc, error)
Lock implements the schema.Locker interface.
func (*Driver) NormalizeRealm ¶ added in v0.3.7
NormalizeRealm returns the normal representation of the given database.
type Enum ¶ added in v0.3.1
type Enum struct { Name string `spec:",name"` Schema *schemaspec.Ref `spec:"schema"` Values []string `spec:"values"` schemaspec.DefaultExtension }
Enum holds a specification for an enum, that can be referenced as a column type.
type IndexColumnProperty ¶
type IndexColumnProperty struct { schema.Attr // NullsFirst defaults to true for DESC indexes. NullsFirst bool // NullsLast defaults to true for ASC indexes. NullsLast bool }
IndexColumnProperty describes an index column property. https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-INFO-INDEX-COLUMN-PROPS
type IndexPredicate ¶
IndexPredicate describes a partial index predicate. https://www.postgresql.org/docs/current/catalog-pg-index.html
type IndexStorageParams ¶ added in v0.4.0
type IndexStorageParams struct { schema.Attr // AutoSummarize defines the authsummarize storage parameter. AutoSummarize bool // PagesPerRange defines pages_per_range storage // parameter for BRIN indexes. Defaults to 128. PagesPerRange int64 }
IndexStorageParams describes index storage parameters add with the WITH clause. https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
type IndexType ¶
IndexType represents an index type. https://www.postgresql.org/docs/current/indexes-types.html
type NetworkType ¶
A NetworkType defines a network type. https://www.postgresql.org/docs/current/datatype-net-types.html
type NoInherit ¶ added in v0.2.0
NoInherit attribute defines the NO INHERIT flag for CHECK constraint. https://www.postgresql.org/docs/current/catalog-pg-constraint.html
type Partition ¶ added in v0.3.8
type Partition struct { schema.Attr // T defines the type/strategy of the partition. // Can be one of: RANGE, LIST, HASH. T string // Partition parts. The additional attributes // on each part can be used to control collation. Parts []*PartitionPart // contains filtered or unexported fields }
Partition defines the spec of a partitioned table.
type PartitionPart ¶ added in v0.3.8
An PartitionPart represents an index part that can be either an expression or a column.
type Sequence ¶ added in v0.2.0
type Sequence struct {
Start, Increment int64
}
Sequence defines (the supported) sequence options. https://www.postgresql.org/docs/current/sql-createsequence.html
type SerialType ¶
A SerialType defines a serial type.
type UserDefinedType ¶
UserDefinedType defines a user-defined type attribute.