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(c string) (schema.Type, error)
- type AutoIncrement
- type CreateStmt
- type Driver
- type File
- type IndexOrigin
- type IndexPredicate
- type UUIDType
- type WithoutRowID
Constants ¶
const ( TypeInteger = "integer" // SQLITE_TYPE_INTEGER TypeReal = "real" // SQLITE_TYPE_REAL TypeText = "text" // SQLITE_TYPE_TEXT TypeBlob = "blob" // SQLITE_TYPE_BLOB )
SQLite standard data types as defined in its codebase and documentation. https://www.sqlite.org/datatype3.html https://github.com/sqlite/sqlite/blob/master/src/global.c
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.WithFormatter(FormatType), schemahcl.WithParser(ParseType), schemahcl.WithSpecs( schemahcl.TypeSpec(TypeReal, schemahcl.WithAttributes(&schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), schemahcl.TypeSpec(TypeBlob, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec(TypeText, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec(TypeInteger, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("int", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("tinyint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("smallint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("mediumint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("bigint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("unsigned_big_int", "unsigned big int", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("int2", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("int8", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("double", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("double_precision", "double precision", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("float", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("character", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("varchar", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("varying_character", "varying character", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("nchar", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("native_character", "native character", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("nvarchar", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("clob", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.TypeSpec("numeric", schemahcl.WithAttributes(&schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), schemahcl.TypeSpec("decimal", schemahcl.WithAttributes(&schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), schemahcl.TypeSpec("boolean"), schemahcl.TypeSpec("date"), schemahcl.TypeSpec("datetime"), schemahcl.TypeSpec("json"), schemahcl.TypeSpec("uuid"), ), )
TypeRegistry contains the supported TypeSpecs for the sqlite driver.
Functions ¶
func FormatType ¶ added in v0.2.0
FormatType converts types to one format. A lowered format. This is due to SQLite flexibility to allow any data types and use a set of rules to define the type affinity. See: https://www.sqlite.org/datatype3.html
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 AutoIncrement ¶ added in v0.1.0
type AutoIncrement struct { schema.Attr // Seq represents the value in sqlite_sequence table. // i.e. https://www.sqlite.org/fileformat2.html#seqtab. // // Setting this value manually to > 0 indicates that // a custom value is necessary and should be handled // on migrate. Seq int64 }
AutoIncrement describes the `AUTOINCREMENT` configuration. https://www.sqlite.org/autoinc.html
type CreateStmt ¶
CreateStmt describes the SQL statement used to create a resource.
type Driver ¶
type Driver struct { schema.Differ schema.Inspector migrate.PlanApplier // contains filtered or unexported fields }
Driver represents a SQLite driver for introspecting database schemas, generating diff between schema elements and apply migrations changes.
type IndexOrigin ¶ added in v0.1.0
IndexOrigin describes how the index was created. See: https://www.sqlite.org/pragma.html#pragma_index_list
type IndexPredicate ¶
IndexPredicate describes a partial index predicate. See: https://www.sqlite.org/partialindex.html
type WithoutRowID ¶
WithoutRowID describes the `WITHOUT ROWID` configuration. See: https://sqlite.org/withoutrowid.html