Documentation ¶
Index ¶
- Variables
- func BoolAttr(k string, v bool) *schemaspec.Attr
- func Check(spec *sqlspec.Check) (*schema.Check, error)
- func Column(spec *sqlspec.Column, conv ConvertTypeFunc) (*schema.Column, error)
- func ColumnByRef(t *schema.Table, ref *schemaspec.Ref) (*schema.Column, error)
- func ColumnRef(cName string) *schemaspec.Ref
- func ConvertGenExpr(r *schemaspec.Resource, c *schema.Column, t func(string) string) error
- func FromCheck(s *schema.Check) *sqlspec.Check
- func FromColumn(col *schema.Column, columnTypeSpec ColumnTypeSpecFunc) (*sqlspec.Column, error)
- func FromForeignKey(s *schema.ForeignKey) (*sqlspec.ForeignKey, error)
- func FromGenExpr(x schema.GeneratedExpr, t func(string) string) *schemaspec.Resource
- func FromIndex(idx *schema.Index, partFns ...func(*schema.IndexPart, *sqlspec.IndexPart)) (*sqlspec.Index, error)
- func FromPrimaryKey(s *schema.Index) (*sqlspec.PrimaryKey, error)
- func FromSchema(s *schema.Schema, fn TableSpecFunc) (*sqlspec.Schema, []*sqlspec.Table, error)
- func FromTable(t *schema.Table, colFn ColumnSpecFunc, pkFn PrimaryKeySpecFunc, ...) (*sqlspec.Table, error)
- func FromVar(s string) string
- func Index(spec *sqlspec.Index, parent *schema.Table, ...) (*schema.Index, error)
- func Int64Attr(k string, v int64) *schemaspec.Attr
- func IntAttr(k string, v int) *schemaspec.Attr
- func ListAttr(k string, litValues ...string) *schemaspec.Attr
- func LitAttr(k, v string) *schemaspec.Attr
- func Marshal(v interface{}, marshaler schemaspec.Marshaler, ...) ([]byte, error)
- func PrimaryKey(spec *sqlspec.PrimaryKey, parent *schema.Table) (*schema.Index, error)
- func QualifyDuplicates(tableSpecs []*sqlspec.Table) error
- func RawAttr(k, v string) *schemaspec.Attr
- func RefAttr(k string, r *schemaspec.Ref) *schemaspec.Attr
- func Scan(r *schema.Realm, schemas []*sqlspec.Schema, tables []*sqlspec.Table, ...) error
- func SchemaName(ref *schemaspec.Ref) (string, error)
- func SchemaRef(n string) *schemaspec.Ref
- func StrAttr(k, v string) *schemaspec.Attr
- func Table(spec *sqlspec.Table, parent *schema.Schema, convertColumn ConvertColumnFunc, ...) (*schema.Table, error)
- func Unmarshal(data []byte, evaluator schemahcl.Evaluator, v interface{}, ...) error
- func Var(s string) string
- func VarAttr(k, v string) *schemaspec.Attr
- type Attrer
- type CheckSpecFunc
- type ColumnSpecFunc
- type ColumnTypeSpecFunc
- type ConvertCheckFunc
- type ConvertColumnFunc
- type ConvertIndexFunc
- type ConvertPrimaryKeyFunc
- type ConvertTableFunc
- type ConvertTypeFunc
- type ForeignKeySpecFunc
- type IndexSpecFunc
- type PrimaryKeySpecFunc
- type TableSpecFunc
Constants ¶
This section is empty.
Variables ¶
var ReferenceVars = []string{ Var(string(schema.NoAction)), Var(string(schema.Restrict)), Var(string(schema.Cascade)), Var(string(schema.SetNull)), Var(string(schema.SetDefault)), }
ReferenceVars holds the HCL variables for foreign keys' referential-actions.
Functions ¶
func BoolAttr ¶ added in v0.3.0
func BoolAttr(k string, v bool) *schemaspec.Attr
BoolAttr is a helper method for constructing *schemaspec.Attr of type bool.
func ColumnByRef ¶ added in v0.3.8
ColumnByRef returns a column from the table by its reference.
func ColumnRef ¶ added in v0.3.8
func ColumnRef(cName string) *schemaspec.Ref
ColumnRef returns the reference of a column by its name.
func ConvertGenExpr ¶ added in v0.3.8
ConvertGenExpr converts the "as" attribute or the block under the given resource.
func FromColumn ¶ added in v0.2.0
FromColumn converts a *schema.Column into a *sqlspec.Column using the ColumnTypeSpecFunc.
func FromForeignKey ¶
func FromForeignKey(s *schema.ForeignKey) (*sqlspec.ForeignKey, error)
FromForeignKey converts schema.ForeignKey to sqlspec.ForeignKey.
func FromGenExpr ¶ added in v0.3.8
func FromGenExpr(x schema.GeneratedExpr, t func(string) string) *schemaspec.Resource
FromGenExpr returns the spec for a generated expression.
func FromIndex ¶
func FromIndex(idx *schema.Index, partFns ...func(*schema.IndexPart, *sqlspec.IndexPart)) (*sqlspec.Index, error)
FromIndex converts schema.Index to sqlspec.Index.
func FromPrimaryKey ¶
func FromPrimaryKey(s *schema.Index) (*sqlspec.PrimaryKey, error)
FromPrimaryKey converts schema.Index to a sqlspec.PrimaryKey.
func FromSchema ¶
FromSchema converts a schema.Schema into sqlspec.Schema and []sqlspec.Table.
func FromTable ¶
func FromTable(t *schema.Table, colFn ColumnSpecFunc, pkFn PrimaryKeySpecFunc, idxFn IndexSpecFunc, fkFn ForeignKeySpecFunc, ckFn CheckSpecFunc) (*sqlspec.Table, error)
FromTable converts a schema.Table to a sqlspec.Table.
func Index ¶
func Index(spec *sqlspec.Index, parent *schema.Table, partFns ...func(*sqlspec.IndexPart, *schema.IndexPart) error) (*schema.Index, error)
Index converts a sqlspec.Index to a schema.Index. The optional arguments allow passing functions for mutating the created index-part (e.g. add attributes).
func Int64Attr ¶ added in v0.3.5
func Int64Attr(k string, v int64) *schemaspec.Attr
Int64Attr is a helper method for constructing *schemaspec.Attr with the numeric value of v.
func IntAttr ¶ added in v0.3.8
func IntAttr(k string, v int) *schemaspec.Attr
IntAttr is a helper method for constructing *schemaspec.Attr with the numeric value of v.
func ListAttr ¶
func ListAttr(k string, litValues ...string) *schemaspec.Attr
ListAttr is a helper method for constructing *schemaspec.Attr instances that contain list values.
func LitAttr ¶
func LitAttr(k, v string) *schemaspec.Attr
LitAttr is a helper method for constructing *schemaspec.Attr instances that contain literal values.
func Marshal ¶ added in v0.2.0
func Marshal(v interface{}, marshaler schemaspec.Marshaler, schemaSpec func(schem *schema.Schema) (*sqlspec.Schema, []*sqlspec.Table, error)) ([]byte, error)
Marshal marshals v into an Atlas DDL document using a schemaspec.Marshaler. Marshal uses the given schemaSpec function to convert a *schema.Schema into *sqlspec.Schema and []*sqlspec.Table.
func PrimaryKey ¶
PrimaryKey converts a sqlspec.PrimaryKey to a schema.Index.
func QualifyDuplicates ¶ added in v0.3.8
QualifyDuplicates sets the Qualified field equal to the schema name in any tables with duplicate names in the provided table specs.
func RawAttr ¶ added in v0.3.2
func RawAttr(k, v string) *schemaspec.Attr
RawAttr is a helper method for constructing *schemaspec.Attr instances that contain sql expressions.
func RefAttr ¶ added in v0.3.8
func RefAttr(k string, r *schemaspec.Ref) *schemaspec.Attr
RefAttr is a helper method for constructing *schemaspec.Attr instances that contain a reference.
func Scan ¶ added in v0.3.8
func Scan(r *schema.Realm, schemas []*sqlspec.Schema, tables []*sqlspec.Table, convertTable ConvertTableFunc) error
Scan populates the Realm from the schemas and table specs.
func SchemaName ¶ added in v0.3.1
func SchemaName(ref *schemaspec.Ref) (string, error)
SchemaName returns the name from a ref to a schema.
func SchemaRef ¶ added in v0.3.1
func SchemaRef(n string) *schemaspec.Ref
SchemaRef returns the schemaspec.Ref to the schema with the given name.
func StrAttr ¶ added in v0.2.0
func StrAttr(k, v string) *schemaspec.Attr
StrAttr is a helper method for constructing *schemaspec.Attr of type string.
func Table ¶
func Table(spec *sqlspec.Table, parent *schema.Schema, convertColumn ConvertColumnFunc, convertPk ConvertPrimaryKeyFunc, convertIndex ConvertIndexFunc, convertCheck ConvertCheckFunc) (*schema.Table, error)
Table converts a sqlspec.Table to a schema.Table. Table conversion is done without converting ForeignKeySpecs into ForeignKeys, as the target tables do not necessarily exist in the schema at this point. Instead, the linking is done by the Schema function.
func Unmarshal ¶ added in v0.2.0
func Unmarshal(data []byte, evaluator schemahcl.Evaluator, v interface{}, input map[string]string, convertTable ConvertTableFunc) error
Unmarshal unmarshals an Atlas DDL document using an unmarshaler into v. Unmarshal uses the given convertTable function to convert a *sqlspec.Table into a *schema.Table.
func Var ¶ added in v0.3.6
Var formats a string as variable to make it HCL compatible. The result is simple, replace each space with underscore.
func VarAttr ¶ added in v0.3.4
func VarAttr(k, v string) *schemaspec.Attr
VarAttr is a helper method for constructing *schemaspec.Attr instances that contain a variable reference.
Types ¶
type Attrer ¶ added in v0.3.0
type Attrer interface {
Attr(string) (*schemaspec.Attr, bool)
}
Attrer is the interface that wraps the Attr method.
type CheckSpecFunc ¶ added in v0.3.0
List of convert function types.
type ColumnSpecFunc ¶
List of convert function types.
type ColumnTypeSpecFunc ¶ added in v0.2.0
List of convert function types.
type ConvertCheckFunc ¶ added in v0.3.0
List of convert function types.
type ConvertColumnFunc ¶
List of convert function types.
type ConvertIndexFunc ¶
List of convert function types.
type ConvertPrimaryKeyFunc ¶
List of convert function types.
type ConvertTableFunc ¶
List of convert function types.
type ConvertTypeFunc ¶
List of convert function types.
type ForeignKeySpecFunc ¶
type ForeignKeySpecFunc func(*schema.ForeignKey) (*sqlspec.ForeignKey, error)
List of convert function types.
type IndexSpecFunc ¶
List of convert function types.
type PrimaryKeySpecFunc ¶
type PrimaryKeySpecFunc func(*schema.Index) (*sqlspec.PrimaryKey, error)
List of convert function types.