mysql

package
v0.0.0-...-f64704c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var Schema table.Tables

Schema MySQL Table Schema

View Source
var TimeFormat = `2006-01-02 15:04:05`

TimeFormat The go time format string for DB times.

Functions

func FormatTime

func FormatTime(tm time.Time) string

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

func ParseCreateTable(createTable string) (tbl table.Table, err error)

ParseCreateTable Parses a MySQL Create Table statement into a table.Table struct

func ReadDump

func ReadDump(filename string) (statements []string, err error)

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 ReadTableNames() (tables []string, err error)

func ReadTables

func ReadTables(conf config.Config) (err error)

ReadTables Reads the database for the project parameter and parses the show create table result for each into table.Table structs

func SetProjectDB

func SetProjectDB(pdb *sql.DB)

SetProjectDB Directly set the Project DB Connection. For unit testing.

func Setup

func Setup(conf config.Config)

Setup Configure the Project DB Connection

Types

type SQLOperation

type SQLOperation struct {
	Statement string
	Op        int
	Name      string
	Metadata  metadata.Metadata
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL