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(c string) (schema.Type, error)
- func UnmarshalSpec(data []byte, unmarshaler schemaspec.Unmarshaler, v interface{}) 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(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(TypeReal, specutil.WithAttributes(&schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), specutil.TypeSpec(TypeBlob, specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec(TypeText, specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec(TypeInteger, specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("int", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("tinyint", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("smallint", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("mediumint", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("bigint", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.AliasTypeSpec("unsigned_big_int", "unsigned big int", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("int2", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("int8", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("double", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.AliasTypeSpec("double_precision", "double precision", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("float", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("character", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("varchar", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.AliasTypeSpec("varying_character", "varying character", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("nchar", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.AliasTypeSpec("native_character", "native character", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("nvarchar", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("clob", specutil.WithAttributes(specutil.SizeTypeAttr(false))), specutil.TypeSpec("numeric", specutil.WithAttributes(&schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), specutil.TypeSpec("decimal", specutil.WithAttributes(&schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), specutil.TypeSpec("boolean"), specutil.TypeSpec("date"), specutil.TypeSpec("datetime"), specutil.TypeSpec("json"), specutil.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.
func ParseType ¶ added in v0.3.0
ParseType returns the schema.Type value represented by the given raw type. It is expected to be one of the types in https://www.sqlite.org/datatypes.html, or some of the common types used by ORMs like Ent.
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 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