Documentation ¶
Index ¶
- type Column
- type IReplacing
- type NamingStrategy
- func (ns NamingStrategy) CheckerName(table, column string) string
- func (ns NamingStrategy) ColumnName(table, column string) string
- func (ns NamingStrategy) IndexName(table, column string) string
- func (ns NamingStrategy) JoinTableName(str string) string
- func (ns NamingStrategy) SchemaName(table string) string
- func (ns NamingStrategy) TableName(str string) string
- func (ns NamingStrategy) UniqueIndexName(table, column string) string
- type Schema
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct { validation.Validatable `json:"-"` Kind data.Kind `json:"kind" yaml:"Kind"` Name string `json:"name" yaml:"Name"` Description string `json:"description" yaml:"Description"` Deprecated string `json:"deprecated" yaml:"Deprecated"` NativeKind string `json:"native_kind" yaml:"NativeKind"` Length int `json:"length" yaml:"Length"` NumericPrecision int `json:"numeric_precision" yaml:"NumericPrecision"` NumericScale int `json:"numeric_scale" yaml:"NumericScale"` DateTimePrecision int `json:"date_time_precision" yaml:"DateTimePrecision"` Codec string `json:"codec" yaml:"Codec"` Charset string `json:"charset" yaml:"Charset"` Default string `json:"default" yaml:"Default"` Validation string `json:"validation" yaml:"Validation"` Replacement string `json:"replacement" yaml:"Replacement"` Sensitive bool `json:"sensitive" yaml:"Sensitive"` AutoIncrement bool `json:"auto_increment" yaml:"AutoIncrement"` Primary bool `json:"primary" yaml:"Primary"` Index bool `json:"index" yaml:"Index"` Unique bool `json:"unique" yaml:"Unique"` Nullable bool `json:"nullable" yaml:"Nullable"` Creatable bool `json:"creatable" yaml:"Creatable"` Updatable bool `json:"updatable" yaml:"Updatable"` Readable bool `json:"readable" yaml:"Readable"` }
Column defines a single Table column structure.
func (*Column) Validate ¶
Validate makes `Column` validatable by implementing validation.Validatable interface.
type IReplacing ¶
IReplacing replacing interface like strings.Replacer
type NamingStrategy ¶
type NamingStrategy struct { SchemaNameLength int `json:"schema_name_length" yaml:"SchemaNameLength"` TableNameLength int `json:"table_name_length" yaml:"TableNameLength"` ColumnNameLength int `json:"column_name_length" yaml:"ColumnNameLength"` TablePrefix string `json:"table_prefix" yaml:"TablePrefix"` ColumnPrefix string `json:"column_prefix" yaml:"ColumnPrefix"` SingularTable bool `json:"singular_table" yaml:"SingularTable"` NoLowerCase bool `json:"no_lower_case" yaml:"NoLowerCase"` NameReplacer IReplacing `json:"-"` }
NamingStrategy naming strategy
func (NamingStrategy) CheckerName ¶
func (ns NamingStrategy) CheckerName(table, column string) string
CheckerName generate checker name
func (NamingStrategy) ColumnName ¶
func (ns NamingStrategy) ColumnName(table, column string) string
ColumnName convert string to column name
func (NamingStrategy) IndexName ¶
func (ns NamingStrategy) IndexName(table, column string) string
IndexName generate index name
func (NamingStrategy) JoinTableName ¶
func (ns NamingStrategy) JoinTableName(str string) string
JoinTableName convert string to join table name
func (NamingStrategy) SchemaName ¶
func (ns NamingStrategy) SchemaName(table string) string
SchemaName generate schema name from table name, don't guarantee it is the reverse value of TableName
func (NamingStrategy) TableName ¶
func (ns NamingStrategy) TableName(str string) string
TableName convert string to table name
func (NamingStrategy) UniqueIndexName ¶
func (ns NamingStrategy) UniqueIndexName(table, column string) string
UniqueIndexName generate unique index name
type Schema ¶
type Schema struct { validation.Validatable `json:"-"` Name string `json:"name" yaml:"Name"` Description string `json:"description" yaml:"Description"` Deprecated string `json:"deprecated" yaml:"Deprecated"` Documentation string `json:"documentation" yaml:"Documentation"` Encoding string `json:"encoding" yaml:"Encoding"` Tables []*Table `json:"tables" yaml:"Tables"` NamingStrategy NamingStrategy `json:"naming_strategy" yaml:"NamingStrategy"` // contains filtered or unexported fields }
Schema defines a single schema structure.
func (*Schema) CreateTable ¶
CreateTable add a single table to the schema.
func (*Schema) TablePosition ¶
TablePosition returns the index of a table by its name.
func (*Schema) Validate ¶
Validate makes Schema validatable by implementing validation.Validatable interface.
type Table ¶
type Table struct { validation.Validatable `json:"-"` Name string `json:"name" yaml:"Name"` Description string `json:"description" yaml:"Description"` Deprecated string `json:"deprecated" yaml:"Deprecated"` Engine string `json:"engine" yaml:"Engine"` Codec string `json:"codec" yaml:"Codec"` Charset string `json:"charset" yaml:"Charset"` ReadOnly bool `json:"read_only" yaml:"ReadOnly"` Columns []*Column `json:"columns" yaml:"Columns"` // contains filtered or unexported fields }
Table defines a single Schema table structure.
func (*Table) ColumnPosition ¶
ColumnPosition returns the index of a column by its name.
func (*Table) CreateColumn ¶
CreateColumn add a single column to the table.
func (*Table) DropColumn ¶
DropColumn delete a single column by its name.
func (*Table) Validate ¶
Validate makes Table validatable by implementing validation.Validatable interface.