Documentation ¶
Index ¶
- type Query
- func (q *Query) AddIndex(table *schema.Table, column *schema.Column) (sql string, e error)
- func (q *Query) AddUniqueIndex(table *schema.Table, column *schema.Column) (sql string, e error)
- func (q *Query) AlterTableCreateColumn(table *schema.Table, column *schema.Column) (sql string, e error)
- func (q *Query) AlterTableDropColumn(table *schema.Table, column *schema.Column) (sql string, e error)
- func (q *Query) ChangeColumn(table *schema.Table, localColumn *schema.Column, remoteColumn *schema.Column) (sql string, e error)
- func (q *Query) CreateChangeSQL(localSchema *schema.Schema, remoteSchema *schema.Schema) (sql string, e error)
- func (q *Query) CreateColumn(column *schema.Column) (sql string, e error)
- func (q *Query) CreateTable(table *schema.Table) (sql string, e error)
- func (q *Query) CreateTableChangeSQL(localTable *schema.Table, remoteTable *schema.Table) (sql string, e error)
- func (q *Query) DropIndex(table *schema.Table, column *schema.Column) (sql string, e error)
- func (q *Query) DropTable(table *schema.Table) (sql string, e error)
- func (q *Query) DropUniqueIndex(table *schema.Table, column *schema.Column) (sql string, e error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct{}
Query contains functionality for generating sql queries
func (*Query) AddIndex ¶
AddIndex returns an alter table sql statement that adds an index to a table
func (*Query) AddUniqueIndex ¶
AddUniqueIndex returns an alter table sql statement that adds a unique index to a table
func (*Query) AlterTableCreateColumn ¶
func (q *Query) AlterTableCreateColumn(table *schema.Table, column *schema.Column) (sql string, e error)
AlterTableCreateColumn returns an alter table sql statement that adds a column
func (*Query) AlterTableDropColumn ¶
func (q *Query) AlterTableDropColumn(table *schema.Table, column *schema.Column) (sql string, e error)
AlterTableDropColumn returns an alter table sql statement that drops a column
func (*Query) ChangeColumn ¶
func (q *Query) ChangeColumn(table *schema.Table, localColumn *schema.Column, remoteColumn *schema.Column) (sql string, e error)
ChangeColumn returns an alter table sql statement that adds or removes an index from a column if and only if the one (e.g. local) has a column and the other (e.g. remote) does not Truth table
Remote | Local | Result
--------------------------------------------------------- 1. MUL | none | Drop index 2. UNI | none | Drop unique index 3. none | MUL | Create index 4. none | UNI | Create unique index 5. MUL | UNI | Drop index; Create unique index 6. UNI | MUL | Drop unique index; Create index 7. none | none | Do nothing 8. MUL | MUL | Do nothing 9. UNI | UNI | Do nothing
func (*Query) CreateChangeSQL ¶
func (q *Query) CreateChangeSQL(localSchema *schema.Schema, remoteSchema *schema.Schema) (sql string, e error)
CreateChangeSQL generates sql statements based off of comparing two database objects localSchema is authority, remoteSchema will be upgraded to match localSchema
func (*Query) CreateColumn ¶
CreateColumn returns a table column sql segment
func (*Query) CreateTable ¶
CreateTable returns a create table sql statement
func (*Query) CreateTableChangeSQL ¶
func (q *Query) CreateTableChangeSQL(localTable *schema.Table, remoteTable *schema.Table) (sql string, e error)
CreateTableChangeSQL returns a set of statements that alter a table's structure if and only if there is a difference between the local and remote tables If no change is found, an empty string is returned.