Help us shape the future of Go! Take the 2026 Go Developer Survey

sql

package
v1.8.14 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

func (q *Query) AddIndex(table *schema.Table, column *schema.Column) (sql string, e error)

AddIndex returns an alter table sql statement that adds an index to a table

func (*Query) AddUniqueIndex

func (q *Query) AddUniqueIndex(table *schema.Table, column *schema.Column) (sql string, e error)

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

func (q *Query) CreateColumn(column *schema.Column) (sql string, e error)

CreateColumn returns a table column sql segment

func (*Query) CreateTable

func (q *Query) CreateTable(table *schema.Table) (sql string, e error)

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.

func (*Query) DropIndex

func (q *Query) DropIndex(table *schema.Table, column *schema.Column) (sql string, e error)

DropIndex returns an alter table sql statement that drops an index

func (*Query) DropTable

func (q *Query) DropTable(table *schema.Table) (sql string, e error)

DropTable returns a drop table sql statement

func (*Query) DropUniqueIndex

func (q *Query) DropUniqueIndex(table *schema.Table, column *schema.Column) (sql string, e error)

DropUniqueIndex returns an alter table sql statement that drops a unique index

Jump to

Keyboard shortcuts

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