Documentation
¶
Index ¶
- Constants
- func DataTypeToFormatString(column *Column) (fieldType string)
- func DataTypeToGoTypeString(column *Column) (fieldType string)
- func DataTypeToTypescriptString(column *Column) (fieldType string)
- func GoTypeFormatString(goType string) (fieldType string)
- func IsString(column *Column) bool
- func IsValidSQLType(str string) bool
- type Column
- type ColumnWithTable
- type Schema
- type SchemaChange
- type SchemaComparison
- type SchemaList
- type Server
- type SortedColumns
- type SortedTables
- type Table
Constants ¶
const ( SchemaTypeMySQL = "mysql" SchemaTypeSQLite = "sqlite" 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" )
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 DataTypeToTypescriptString ¶ added in v1.8.19
TODO move to mysql specific TODO make column types constants in mysql
func GoTypeFormatString ¶ added in v1.7.7
DataTypeToFormatString converts a database type to its equivalent golang datatype
func IsValidSQLType ¶
DataTypeToGoTypeString converts a database type to its equivalent golang datatype
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"`
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 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:"-"`
}
Schema represents a database
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"`
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