Documentation ¶
Index ¶
- Constants
- func DataTypeToFormatString(column *Column) (fieldType string)
- func DataTypeToGoTypeString(column *Column) (fieldType string)
- func DataTypeToTypescriptDefault(dataType string) (fieldType string)
- func DataTypeToTypescriptString(dbDataType string) (fieldType string)
- func ExtractBaseGoType(goDataType string) string
- func GoBaseTypeToBaseTypescriptDefault(goDataType string) string
- func GoBaseTypeToBaseTypescriptType(goDataType string) string
- func GoTypeFormatString(goType string) (fieldType string)
- func GoTypeToTypescriptDefault(goDataType string) (fieldType string)
- func GoTypeToTypescriptString(goDataType string) string
- func IsGoTypeBaseType(goDataType string) bool
- func IsString(column *Column) bool
- func IsValidSQLType(str string) bool
- func ParseMapTypeToTypescriptString(goDataType string) string
- type Column
- type ColumnWithTable
- type Database
- type Schema
- type SchemaChange
- type SchemaComparison
- type SchemaList
- type Server
- type SortedColumns
- type SortedTables
- type Table
Constants ¶
const ( SchemaTypeMySQL = "mysql" SchemaTypePostgreSQL = "postgresql" SchemaTypeSQLServer = "sqlserver" )
const ( RenameTable = "RENAME_TABLE" CreateTable = "CREATE_TABLE" DropTable = "DROP_TABLE" ChangeColumn = "CHANGE_COLUMN" AddColumn = "ADD_COLUMN" DropColumn = "DROP_COLUMN" AddIndex = "ADD_INDEX" DropIndex = "DROP_INDEX" ChangeCharacterSet = "CHANGE_CHARACTER_SET" )
Variables ¶
This section is empty.
Functions ¶
func DataTypeToFormatString ¶
DataTypeToFormatString converts a database type to its equivalent golang datatype TODO move to mysql specific TODO make column types constants in mysql
func DataTypeToGoTypeString ¶
DataTypeToGoTypeString converts a database type to its equivalent golang datatype
func DataTypeToTypescriptDefault ¶ added in v1.8.45
TODO move to mysql specific TODO make column types constants in mysql
func DataTypeToTypescriptString ¶ added in v1.8.19
TODO move to mysql specific TODO make column types constants in mysql
func ExtractBaseGoType ¶ added in v1.8.67
func GoBaseTypeToBaseTypescriptDefault ¶ added in v1.8.67
func GoBaseTypeToBaseTypescriptType ¶ added in v1.8.67
func GoTypeFormatString ¶ added in v1.7.7
DataTypeToFormatString converts a database type to its equivalent golang datatype
func GoTypeToTypescriptDefault ¶ added in v1.8.48
func GoTypeToTypescriptString ¶ added in v1.8.48
func IsGoTypeBaseType ¶ added in v1.8.67
func IsValidSQLType ¶
DataTypeToGoTypeString converts a database type to its equivalent golang datatype
func ParseMapTypeToTypescriptString ¶ added in v1.8.74
Types ¶
type Column ¶
type Column struct { Name string `json:"column"` // Position int `json:"position"` Default string `json:"default"` IsNullable bool `json:"isNullable"` IsUnsigned bool `json:"isUnsigned"` DataType string `json:"dataType"` MaxLength int `json:"maxLength"` Precision int `json:"precision"` CharSet string `json:"charSet"` Collation string `json:"collation"` Type string `json:"type"` ColumnKey string `json:"columnKey"` NumericScale int `json:"numericScale"` Extra string `json:"extra"` FmtType string `json:"fmtType"` GoType string `json:"goType"` IsString bool `json:"isString"` }
Column represents a column in a table
type ColumnWithTable ¶
ColumnWithTable is a column with the table name included
type Database ¶ added in v1.8.48
type Database struct { RunID int64 `json:"-"` Name string `json:"name"` SortedSetKeys []string `json:"-"` Tables map[string]*Table `json:"tables"` Enums map[string][]map[string]interface{} `json:"-"` DefaultCharacterSet string `json:"defaultCharacterSet"` DefaultCollation string `json:"defaultCollation"` }
Database represents a database
type Schema ¶
type Schema struct { RunID int64 `json:"-"` Name string `json:"name"` SortedSetKeys []string `json:"-"` Tables map[string]*Table `json:"tables"` Enums map[string][]map[string]interface{} `json:"-"` DefaultCharacterSet string `json:"defaultCharacterSet"` DefaultCollation string `json:"defaultCollation"` }
Schema represents a database structure
func (*Schema) FindTableByName ¶
FindTableByName finds a table by its name in the database
func (*Schema) ToSortedTables ¶
func (s *Schema) ToSortedTables() SortedTables
ToSortedTables returns SortedTables
type SchemaChange ¶
type SchemaComparison ¶
type SchemaList ¶
type SchemaList struct {
Schemas []*Schema `json:"schemas"`
}
func LoadLocalSchemas ¶
func LoadLocalSchemas() (*SchemaList, error)
loadDatabase loads a database from configuration
type Server ¶
type Server struct { Name string `json:"name"` Host string `json:"host"` Databases map[string]*Schema Connection *sql.DB CurrentDatabase string }
Server represents a server
func (*Server) SchemaExists ¶
SchemaExists checks if the database `databaseName` exists in its list of databases
type SortedColumns ¶
type SortedColumns []*Column
SortedColumns is a slice of Column objects
func (SortedColumns) Less ¶
func (c SortedColumns) Less(i, j int) bool
Less is part of sort.Interface. We use count as the value to sort by
type SortedTables ¶
type SortedTables []*Table
SortedTables is a slice of Table objects
func (SortedTables) Less ¶
func (c SortedTables) Less(i, j int) bool
Less is part of sort.Interface. We use count as the value to sort by
type Table ¶
type Table struct { Name string `json:"name"` Engine string `json:"engine"` Version int `json:"version"` RowFormat string `json:"rowFormat"` Rows int64 `json:"-"` DataLength int64 `json:"-"` Collation string `json:"collation"` CharacterSet string `json:"characterSet"` AutoIncrement int64 `json:"-"` Columns map[string]*Column `json:"columns"` }
Table represents a table in a database
func (*Table) ToSortedColumns ¶
func (table *Table) ToSortedColumns() SortedColumns
ToSortedColumns returns SortedColumns