Documentation ¶
Index ¶
- func Diff(db *sql.DB, filename string, src interface{}) ([]string, error)
- func Fprint(output io.Writer, db *sql.DB) error
- func Sync(db *sql.DB, filename string, src interface{}) error
- type Index
- type Table
- type TableAST
- func (t *TableAST) AlterTableQueries(d dialect.Dialect, currentTable *Table) ([]string, error)
- func (t *TableAST) ColumnMap() map[string]*field
- func (t *TableAST) Columns() ([]*field, error)
- func (t *TableAST) CreateTableQuery(d dialect.Dialect) ([]string, error)
- func (t *TableAST) GenerateAddFieldSQLs(d dialect.Dialect, currentColumMap map[string]*columnSchema) ([]string, error)
- func (t *TableAST) GenerateAddIndexSQLs(d dialect.Dialect, currentIndexMap map[string]*Index) ([]string, error)
- func (t *TableAST) GenerateDropFieldSQLs(d dialect.Dialect, currentColumMap map[string]*columnSchema) ([]string, error)
- func (t *TableAST) GenerateDropIndexSQLs(d dialect.Dialect, currentIndexMap map[string]*Index) ([]string, error)
- func (t *TableAST) GenerateModifyFieldSQLs(d dialect.Dialect, currentColumMap map[string]*columnSchema) ([]string, error)
- func (t *TableAST) HasSchema() bool
- func (t *TableAST) IndexMap() map[string]*Index
- func (t *TableAST) Indexes() ([]*Index, error)
- func (t *TableAST) MustColumns() []*field
- func (t *TableAST) MustIndexes() []*Index
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sync ¶
Sync synchronizes the schema between Go's struct and the database. Go's struct may be provided via the filename of the source file, or via the src parameter.
If src != nil, Sync parses the source from src and filename is not used. The type of the argument for the src parameter must be string, []byte, or io.Reader. If src == nil, Sync parses the file specified by filename.
All query for synchronization will be performed within the transaction if storage engine supports the transaction. (e.g. MySQL's MyISAM engine does NOT support the transaction)
Types ¶
type Table ¶ added in v0.1.1
type Table struct { Columns []*columnSchema Indexes []*Index }
Table is table definitions
func (Table) HasDatetimeColumn ¶ added in v0.1.1
type TableAST ¶ added in v0.1.1
type TableAST struct { Name string Schema *ast.StructType IndexSchema *ast.StructType }
func (*TableAST) AlterTableQueries ¶ added in v0.1.1
func (*TableAST) CreateTableQuery ¶ added in v0.1.1
see: https://dev.mysql.com/doc/refman/5.6/en/create-table.html
func (*TableAST) GenerateAddFieldSQLs ¶ added in v0.1.1
func (*TableAST) GenerateAddIndexSQLs ¶ added in v0.1.1
func (*TableAST) GenerateDropFieldSQLs ¶ added in v0.1.1
func (*TableAST) GenerateDropIndexSQLs ¶ added in v0.1.1
func (*TableAST) GenerateModifyFieldSQLs ¶ added in v0.1.1
func (*TableAST) MustColumns ¶ added in v0.1.1
func (t *TableAST) MustColumns() []*field
func (*TableAST) MustIndexes ¶ added in v0.1.1
Click to show internal directories.
Click to hide internal directories.