Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateSchema(schemaDialect SchemaDialect, t *Table) string
- func GenerateSchemaCreateIndex(schemaDialect SchemaDialect, table *Table, index *Index) string
- func GenerateSchemaCreateTable(schemaDialect SchemaDialect, table *Table) string
- type AutoIncrementKeyword
- type BigIntFieldType
- type BlobFieldType
- type BooleanFieldType
- type ConditionalStringSliceAppender
- type CreatedFieldType
- type DateTimeFieldType
- type DefaultKeyword
- type DialectVisitor
- type Field
- type FieldType
- type FieldTypeVisitor
- type Index
- type IndexKeyword
- type IntegerFieldType
- type NotNullKeyword
- type NullKeyword
- type PrimaryKeyKeyword
- type RealFieldType
- type SchemaDialect
- type SchemaKeyword
- type ShemaKeywordVisitor
- type Table
- type TableBuilder
- type TimeStampFieldType
- type UniqueIndexKeyword
- type UpdatedFieldType
- type VarcharFieldType
Constants ¶
View Source
const (
DEFAULT_VARCHAR_SIZE = 200
)
Variables ¶
View Source
var ( MysqlSchemaDialect = NewMysqlSchemaDialect() SqliteSchemaDialect = NewSqliteSchemaDialect() PostgresSchemaDialect = NewPostgresSchemaDialect() )
View Source
var ( INTEGER = &IntegerFieldType{} BIGINT = &BigIntFieldType{} VARCHAR = &VarcharFieldType{} BOOLEAN = &BooleanFieldType{} REAL = &RealFieldType{} BLOB = &BlobFieldType{} DATETIME = &DateTimeFieldType{} TIMESTAMP = &TimeStampFieldType{} CREATED = &CreatedFieldType{} UPDATED = &UpdatedFieldType{} )
View Source
var ( AUTO_INCREMENT = &AutoIncrementKeyword{} PRIMARY_KEY = &PrimaryKeyKeyword{} INDEX = &IndexKeyword{} UNIQUE_INDEX = &UniqueIndexKeyword{} NULL = &NullKeyword{} NOT_NULL = &NotNullKeyword{} DEFAULT = &DefaultKeyword{} )
List of vendor-specific keywords
Functions ¶
func GenerateSchema ¶
func GenerateSchema(schemaDialect SchemaDialect, t *Table) string
func GenerateSchemaCreateIndex ¶
func GenerateSchemaCreateIndex(schemaDialect SchemaDialect, table *Table, index *Index) string
func GenerateSchemaCreateTable ¶
func GenerateSchemaCreateTable(schemaDialect SchemaDialect, table *Table) string
Types ¶
type AutoIncrementKeyword ¶
type AutoIncrementKeyword struct{}
func (*AutoIncrementKeyword) Accept ¶
func (a *AutoIncrementKeyword) Accept(visitor ShemaKeywordVisitor)
type BigIntFieldType ¶ added in v0.0.5
type BigIntFieldType struct{}
func (*BigIntFieldType) Accept ¶ added in v0.0.5
func (b *BigIntFieldType) Accept(visitor FieldTypeVisitor)
type BlobFieldType ¶
type BlobFieldType struct{}
func (*BlobFieldType) Accept ¶
func (b *BlobFieldType) Accept(visitor FieldTypeVisitor)
type BooleanFieldType ¶
type BooleanFieldType struct{}
func (*BooleanFieldType) Accept ¶
func (b *BooleanFieldType) Accept(visitor FieldTypeVisitor)
type ConditionalStringSliceAppender ¶
type ConditionalStringSliceAppender struct {
// contains filtered or unexported fields
}
func (*ConditionalStringSliceAppender) Append ¶
func (c *ConditionalStringSliceAppender) Append(s ...string)
func (*ConditionalStringSliceAppender) AppendWithCondition ¶
func (c *ConditionalStringSliceAppender) AppendWithCondition(condition bool, s ...string)
func (*ConditionalStringSliceAppender) Slice ¶
func (c *ConditionalStringSliceAppender) Slice() []string
type CreatedFieldType ¶
type CreatedFieldType struct{}
func (*CreatedFieldType) Accept ¶
func (c *CreatedFieldType) Accept(visitor FieldTypeVisitor)
type DateTimeFieldType ¶
type DateTimeFieldType struct{}
func (*DateTimeFieldType) Accept ¶
func (d *DateTimeFieldType) Accept(visitor FieldTypeVisitor)
type DefaultKeyword ¶
type DefaultKeyword struct{}
func (*DefaultKeyword) Accept ¶
func (d *DefaultKeyword) Accept(visitor ShemaKeywordVisitor)
type DialectVisitor ¶
type DialectVisitor interface { VisitMysql(*mysql) VisitSqlite(*sqlite) VisitPostgres(*postgres) }
type FieldTypeVisitor ¶
type FieldTypeVisitor interface { VisitInteger(*IntegerFieldType) VisitBigInt(*BigIntFieldType) VisitVarchar(*VarcharFieldType) VisitBoolean(*BooleanFieldType) VisitReal(*RealFieldType) VisitBlob(*BlobFieldType) VisitDateTime(*DateTimeFieldType) VisitTimeStamp(*TimeStampFieldType) VisitCreated(*CreatedFieldType) VisitUpdated(*UpdatedFieldType) }
type IndexKeyword ¶
type IndexKeyword struct{}
func (*IndexKeyword) Accept ¶
func (i *IndexKeyword) Accept(visitor ShemaKeywordVisitor)
type IntegerFieldType ¶
type IntegerFieldType struct{}
func (*IntegerFieldType) Accept ¶
func (i *IntegerFieldType) Accept(visitor FieldTypeVisitor)
type NotNullKeyword ¶
type NotNullKeyword struct{}
func (*NotNullKeyword) Accept ¶
func (n *NotNullKeyword) Accept(visitor ShemaKeywordVisitor)
type NullKeyword ¶
type NullKeyword struct{}
func (*NullKeyword) Accept ¶
func (n *NullKeyword) Accept(visitor ShemaKeywordVisitor)
type PrimaryKeyKeyword ¶
type PrimaryKeyKeyword struct{}
func (*PrimaryKeyKeyword) Accept ¶
func (p *PrimaryKeyKeyword) Accept(visitor ShemaKeywordVisitor)
type RealFieldType ¶
type RealFieldType struct{}
func (*RealFieldType) Accept ¶
func (r *RealFieldType) Accept(visitor FieldTypeVisitor)
type SchemaDialect ¶
type SchemaDialect interface { databases.Dialect Accept(DialectVisitor) IndexNameFromFieldNames(fieldNames ...string) (string, error) }
func NewMysqlSchemaDialect ¶
func NewMysqlSchemaDialect() SchemaDialect
func NewPostgresSchemaDialect ¶
func NewPostgresSchemaDialect() SchemaDialect
func NewSqliteSchemaDialect ¶
func NewSqliteSchemaDialect() SchemaDialect
func ParseSchemaDialectFromString ¶
func ParseSchemaDialectFromString(dialectStr string) SchemaDialect
type SchemaKeyword ¶
type SchemaKeyword interface {
Accept(ShemaKeywordVisitor)
}
type ShemaKeywordVisitor ¶
type ShemaKeywordVisitor interface { VisitAutoIncrement(*AutoIncrementKeyword) VisitPrimaryKey(*PrimaryKeyKeyword) VisitIndex(*IndexKeyword) VisitUniqueIndex(*UniqueIndexKeyword) VisitNull(*NullKeyword) VisitNotNull(*NotNullKeyword) VisitDefault(*DefaultKeyword) }
type TableBuilder ¶
type TableBuilder interface { Field(name string, fieldType FieldType, primary, auto bool, size int) TableBuilder FieldWithDefault(name string, fieldType FieldType, primary, auto bool, size int, defaultValue string) TableBuilder NullableField(name string, fieldType FieldType, size int) TableBuilder Primary(fieldNames ...string) TableBuilder Index(name string, unique bool, fieldNames ...string) TableBuilder Build() *Table }
func NewTableBuilder ¶
func NewTableBuilder(tableName string) TableBuilder
type TimeStampFieldType ¶
type TimeStampFieldType struct{}
func (*TimeStampFieldType) Accept ¶
func (t *TimeStampFieldType) Accept(visitor FieldTypeVisitor)
type UniqueIndexKeyword ¶
type UniqueIndexKeyword struct{}
func (*UniqueIndexKeyword) Accept ¶
func (u *UniqueIndexKeyword) Accept(visitor ShemaKeywordVisitor)
type UpdatedFieldType ¶
type UpdatedFieldType struct{}
func (*UpdatedFieldType) Accept ¶
func (u *UpdatedFieldType) Accept(visitor FieldTypeVisitor)
type VarcharFieldType ¶
type VarcharFieldType struct{}
func (*VarcharFieldType) Accept ¶
func (v *VarcharFieldType) Accept(visitor FieldTypeVisitor)
Source Files
¶
- conditional_string_slice_appender.go
- constants.go
- dialect.go
- dialect_mysql.go
- dialect_postgres.go
- dialect_schema_create_index.go
- dialect_schema_create_table.go
- dialect_sqlite.go
- dialect_visitor.go
- field_type_conversion.go
- field_types.go
- generator.go
- keywords.go
- schema.go
- tab_writer.go
- table_builder.go
Click to show internal directories.
Click to hide internal directories.