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 ParseType(typ string) (schema.Type, error)
- func Realm(schemas []*sqlspec.Schema, tables []*sqlspec.Table, enums []*Enum) (*schema.Realm, error)
- func Schema(spec *sqlspec.Schema, tables []*sqlspec.Table, enums []*Enum) (*schema.Schema, error)
- func UnmarshalSpec(data []byte, unmarshaler schemaspec.Unmarshaler, v interface{}) error
- type ArrayType
- type BitType
- type CType
- type CheckColumns
- type ConType
- type CurrencyType
- type Driver
- type Enum
- type Identity
- type IndexColumnProperty
- type IndexPredicate
- type IndexType
- type NetworkType
- type NoInherit
- type Sequence
- type SerialType
- type UUIDType
- type UserDefinedType
- type XMLType
Constants ¶
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 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.
Variables ¶
var ( // UnmarshalHCL unmarshals an Atlas HCL DDL document into v. UnmarshalHCL = schemaspec.UnmarshalerFunc(func(bytes []byte, i interface{}) error { return UnmarshalSpec(bytes, hclState, i) }) // MarshalHCL marshals v into an Atlas HCL DDL document. MarshalHCL = schemaspec.MarshalerFunc(func(v interface{}) ([]byte, error) { return MarshalSpec(v, hclState) }) )
var TypeRegistry = specutil.NewRegistry( specutil.WithFormatter(FormatType), specutil.WithParser(ParseType), specutil.WithSpecs( specutil.TypeSpec(TypeBit, specutil.WithAttributes(&schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64})), specutil.AliasTypeSpec("bit_varying", TypeBitVar, specutil.WithAttributes(&schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64})), specutil.TypeSpec(TypeVarChar, specutil.WithAttributes(specutil.SizeTypeAttr(true))), specutil.AliasTypeSpec("character_varying", TypeCharVar, specutil.WithAttributes(&schemaspec.TypeAttr{Name: "size", Kind: reflect.Int})), specutil.TypeSpec(TypeChar, specutil.WithAttributes(specutil.SizeTypeAttr(true))), specutil.TypeSpec(TypeCharacter, specutil.WithAttributes(specutil.SizeTypeAttr(true))), specutil.TypeSpec(TypeInt2), specutil.TypeSpec(TypeInt4), specutil.TypeSpec(TypeInt8), specutil.TypeSpec(TypeInt), specutil.TypeSpec(TypeInteger), specutil.TypeSpec(TypeSmallInt), specutil.TypeSpec(TypeBigInt), specutil.TypeSpec(TypeText), specutil.TypeSpec(TypeBoolean), specutil.TypeSpec(TypeBool), specutil.TypeSpec(TypeBytea), specutil.TypeSpec(TypeCIDR), specutil.TypeSpec(TypeInet), specutil.TypeSpec(TypeMACAddr), specutil.TypeSpec(TypeMACAddr8), specutil.TypeSpec(TypeCircle), specutil.TypeSpec(TypeLine), specutil.TypeSpec(TypeLseg), specutil.TypeSpec(TypeBox), specutil.TypeSpec(TypePath), specutil.TypeSpec(TypePoint), specutil.TypeSpec(TypeDate), specutil.TypeSpec(TypeTime), specutil.AliasTypeSpec("time_with_time_zone", TypeTimeWTZ), specutil.AliasTypeSpec("time_without_time_zone", TypeTimeWOTZ), specutil.TypeSpec(TypeTimestampTZ), specutil.TypeSpec(TypeTimestamp), specutil.AliasTypeSpec("timestamp_with_time_zone", TypeTimestampWTZ), specutil.AliasTypeSpec("timestamp_without_time_zone", TypeTimestampWOTZ), specutil.AliasTypeSpec("double_precision", TypeDouble), specutil.TypeSpec(TypeReal), specutil.TypeSpec(TypeFloat8), specutil.TypeSpec(TypeFloat4), specutil.TypeSpec(TypeNumeric), specutil.TypeSpec(TypeDecimal), specutil.TypeSpec(TypeSmallSerial), specutil.TypeSpec(TypeSerial), specutil.TypeSpec(TypeBigSerial), specutil.TypeSpec(TypeSerial2), specutil.TypeSpec(TypeSerial4), specutil.TypeSpec(TypeSerial8), specutil.TypeSpec(TypeXML), specutil.TypeSpec(TypeJSON), specutil.TypeSpec(TypeJSONB), specutil.TypeSpec(TypeUUID), specutil.TypeSpec(TypeMoney), specutil.TypeSpec("hstore"), specutil.TypeSpec("sql", specutil.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.
func ParseType ¶ added in v0.3.1
ParseType returns the schema.Type value represented by the given raw type. The raw value is expected to follow the format in PostgreSQL information schema or as an input for the CREATE TABLE statement.
func Realm ¶ added in v0.3.1
func Realm(schemas []*sqlspec.Schema, tables []*sqlspec.Table, enums []*Enum) (*schema.Realm, error)
Realm converts the schemas and tables of the doc into a schema.Realm.
func Schema ¶ added in v0.3.1
Schema converts a sqlspec.Schema with its relevant []sqlspec.Tables and []Enum into a schema.Schema.
func UnmarshalSpec ¶
func UnmarshalSpec(data []byte, unmarshaler schemaspec.Unmarshaler, v interface{}) error
UnmarshalSpec unmarshals an Atlas DDL document using an unmarshaler into v.
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.
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 ¶
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 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 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.