Documentation ¶
Index ¶
- Constants
- Variables
- func FormatType(t schema.Type) (string, error)
- func MarshalSpec(v any, marshaler schemahcl.Marshaler) ([]byte, error)
- func Open(db schema.ExecQuerier) (migrate.Driver, error)
- func ParseType(c string) (schema.Type, error)
- type AutoIncrement
- type CreateStmt
- type Diff
- func (d *Diff) ColumnChange(_ *schema.Table, from, to *schema.Column) (schema.ChangeKind, error)
- func (*Diff) IndexAttrChanged(from, to []schema.Attr) bool
- func (*Diff) IndexPartAttrChanged(_, _ *schema.IndexPart) bool
- func (d *Diff) IsGeneratedIndexName(t *schema.Table, idx *schema.Index) bool
- func (d *Diff) Normalize(from, to *schema.Table) error
- func (*Diff) ReferenceChanged(from, to schema.ReferenceOption) bool
- func (d *Diff) SchemaAttrDiff(_, _ *schema.Schema) []schema.Change
- func (d *Diff) TableAttrDiff(from, to *schema.Table) ([]schema.Change, error)
- 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
const DriverName = "sqlite3"
DriverName holds the name used for registration.
Variables ¶
var ( // MarshalHCL marshals v into an Atlas HCL DDL document. MarshalHCL = schemahcl.MarshalerFunc(func(v any) ([]byte, error) { return MarshalSpec(v, hclState) }) // EvalHCL implements the schemahcl.Evaluator interface. EvalHCL = schemahcl.EvalFunc(evalSpec) // EvalHCLBytes is a helper that evaluates an HCL document from a byte slice instead // of from an hclparse.Parser instance. EvalHCLBytes = specutil.HCLBytesFunc(EvalHCL) )
var TypeRegistry = schemahcl.NewRegistry( schemahcl.WithFormatter(FormatType), schemahcl.WithParser(ParseType), schemahcl.WithSpecs( schemahcl.NewTypeSpec(TypeReal, schemahcl.WithAttributes(&schemahcl.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemahcl.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), schemahcl.NewTypeSpec(TypeBlob, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec(TypeText, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec(TypeInteger, schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("int", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("tinyint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("smallint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("mediumint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("bigint", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("unsigned_big_int", "unsigned big int", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("int2", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("int8", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("double", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("double_precision", "double precision", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("float", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("character", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("varchar", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("varying_character", "varying character", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("nchar", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.AliasTypeSpec("native_character", "native character", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("nvarchar", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("clob", schemahcl.WithAttributes(schemahcl.SizeTypeAttr(false))), schemahcl.NewTypeSpec("numeric", schemahcl.WithAttributes(&schemahcl.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemahcl.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), schemahcl.NewTypeSpec("decimal", schemahcl.WithAttributes(&schemahcl.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemahcl.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false})), schemahcl.NewTypeSpec("bool"), schemahcl.NewTypeSpec("boolean"), schemahcl.NewTypeSpec("date"), schemahcl.NewTypeSpec("datetime"), schemahcl.NewTypeSpec("json"), schemahcl.NewTypeSpec("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 ¶
MarshalSpec marshals v into an Atlas DDL document using a schemahcl.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 Diff ¶ added in v0.5.0
type Diff struct{}
A Diff provides a SQLite implementation for sqlx.DiffDriver.
func (*Diff) ColumnChange ¶ added in v0.5.0
ColumnChange returns the schema changes (if any) for migrating one column to the other.
func (*Diff) IndexAttrChanged ¶ added in v0.5.0
IndexAttrChanged reports if the index attributes were changed.
func (*Diff) IndexPartAttrChanged ¶ added in v0.5.0
IndexPartAttrChanged reports if the index-part attributes were changed.
func (*Diff) IsGeneratedIndexName ¶ added in v0.5.0
IsGeneratedIndexName reports if the index name was generated by the database. See: https://github.com/sqlite/sqlite/blob/e937df8/src/build.c#L3583.
func (*Diff) ReferenceChanged ¶ added in v0.5.0
func (*Diff) ReferenceChanged(from, to schema.ReferenceOption) bool
ReferenceChanged reports if the foreign key referential action was changed.
func (*Diff) SchemaAttrDiff ¶ added in v0.5.0
SchemaAttrDiff returns a changeset for migrating schema attributes from one state to the other.
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.
func (*Driver) CheckClean ¶ added in v0.6.0
CheckClean implements migrate.CleanChecker.
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