Documentation ¶
Index ¶
- Constants
- Variables
- func FormatTime(tm time.Time) string
- func GetTimeNow() string
- func ParseCreateTable(createTable string) (tbl table.Table, err error)
- func ReadDump(filename string) (statements []string, err error)
- func ReadTableNames() (tables []string, err error)
- func ReadTables(conf config.Config) (err error)
- func SetProjectDB(pdb *sql.DB)
- func Setup(conf config.Config)
- type SQLOperation
- type SQLOperations
- type StatementBuilder
- func (sb *StatementBuilder) Add(component string)
- func (sb *StatementBuilder) AddFormat(format string, info ...interface{})
- func (sb *StatementBuilder) AddQuote(component string)
- func (sb *StatementBuilder) AddType(typename string, size []int)
- func (sb StatementBuilder) Format() string
- func (sb *StatementBuilder) Reset()
Constants ¶
const ( NULL = "NULL" DEFAULT = "DEFAULT" NOT_NULL = "NOT NULL" UNSIGNED = "UNSIGNED" AUTO_INCREMENT = "AUTO_INCREMENT" ENGINE = "ENGINE" DEFAULT_CHARSET = "DEFAULT CHARSET" ROW_FORMAT = "ROW_FORMAT" COLLATE = "COLLATE" DEFAULT_COLLATE = "DEFAULT COLLATE" CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP" ON_UPDATE = "ON UPDATE" )
MySQL Keywords
Variables ¶
var Schema table.Tables
Schema MySQL Table Schema
var TimeFormat = `2006-01-02 15:04:05`
TimeFormat The go time format string for DB times.
Functions ¶
func FormatTime ¶
FormatTime Return the current time as a string in MySQL time format
func GetTimeNow ¶
func GetTimeNow() string
GetTimeNow Return the current time as a string in MySQL time format
func ParseCreateTable ¶
ParseCreateTable Parses a MySQL Create Table statement into a table.Table struct
func ReadDump ¶
ReadDump Read a MySQL Dump file as a source of MySQL Schema and return the CREATE TABLE statements as an array of strings
func ReadTableNames ¶
func ReadTables ¶
ReadTables Reads the database for the project parameter and parses the show create table result for each into table.Table structs
func SetProjectDB ¶
SetProjectDB Directly set the Project DB Connection. For unit testing.
Types ¶
type SQLOperation ¶
SQLOperation Stores the data associated with an alter operation for each migration step
type SQLOperations ¶
type SQLOperations []SQLOperation
SQLOperations Slice helper type
func GenerateAlters ¶
func GenerateAlters(differences table.Differences) (operations SQLOperations)
GenerateAlters Generate MySQL ALTER TABLE statements from the Differences between Table structs
func (*SQLOperations) Add ¶
func (s *SQLOperations) Add(op SQLOperation)
Add Add an SQLOperation to the slice
func (*SQLOperations) Merge ¶
func (s *SQLOperations) Merge(ops SQLOperations)
Merge Merge SQLOperations slices
type StatementBuilder ¶
type StatementBuilder struct {
Components []string
}
StatementBuilder Helper for building SQL ALTER TABLE statements. Assists with string concatenation and SQL specific formatting requirements.
func (*StatementBuilder) Add ¶
func (sb *StatementBuilder) Add(component string)
Add Add a new statement component
func (*StatementBuilder) AddFormat ¶
func (sb *StatementBuilder) AddFormat(format string, info ...interface{})
AddFormat Add a new formatted statement component
func (*StatementBuilder) AddQuote ¶
func (sb *StatementBuilder) AddQuote(component string)
AddQuote Add a new component with `quotes`
func (*StatementBuilder) AddType ¶
func (sb *StatementBuilder) AddType(typename string, size []int)
AddType Add a component which correctly formats type size it it's provided
func (StatementBuilder) Format ¶
func (sb StatementBuilder) Format() string
Format Produce a formatted String
func (*StatementBuilder) Reset ¶
func (sb *StatementBuilder) Reset()
Reset Empties the statements components