Documentation ¶
Index ¶
Constants ¶
const ( // AddAll is the option that tells some generator methods to not check if things exist and just add them all AddAll uint8 = 0x000 // AddMissing is the option that tells some generator methods to check if things exist and skip over them if they do AddMissing uint8 = 0x001 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface { // CreateTable returns a string query which creates a full table with columns columns and primary key CreateTable(table string, t schema.Table) string // AddColumn returns a string query which adds the specified column to a table AddColumn(table, column string, c schema.Column) string // AddIndex returns a string query which adds the specified index to a table AddIndex(table, index string, i schema.Index) string // AddReference returns a string query which adds the specified index to a table AddReference(table string, dt schema.Table, i schema.Reference) string }
Adapter describes an internal dialect to be used by Yoyo for generating Migration code for a given DBMS.
func LoadAdapter ¶
LoadAdapter loads and returns an implementation of Adapter corresponding to the given name string
type AdapterLoader ¶
type Generator ¶
type Generator func(db schema.Database, w io.StringWriter) error
Generator functions take a schema.Database and io.StringWriter, generating stuff for the Database to the io.StringWriter
func NewGenerator ¶
func NewGenerator( createTable TableGenerator, addMissingColumns TableGenerator, addMissingIndices TableGenerator, addAllIndices TableGenerator, hasTable StringSearcher, addMissingRefs RefGenerator, addAllRefs RefGenerator, ) Generator
NewGenerator returns a function that generates a schema and writes it to the given io.StringWriter.
type GeneratorLoader ¶
func InitGeneratorLoader ¶
func InitGeneratorLoader( initReverseAdapter func(dia string) (adapter reverse.Adapter, err error), initMigrationAdapter func(dia string) (a Adapter, err error), newGenerator func(TableGenerator, TableGenerator, TableGenerator, TableGenerator, StringSearcher, RefGenerator, RefGenerator) Generator, ) GeneratorLoader
type RefGenerator ¶
RefGenerator functions take a string, map[string]schema.Reference, and io.StringWriter. Implementations will use them to generate SQL for working with references
func NewRefAdder ¶
func NewRefAdder( a Adapter, db schema.Database, options uint8, hasReference reverse.TableSearcher, ) RefGenerator
NewRefAdder returns a RefGenerator that adds references to a given table.
type StringSearcher ¶
StringSearcher functions take a string and return true if the matching entity (table, column, etc) exists.
type TableGenerator ¶
type TableGenerator func(table schema.Table, sw io.StringWriter) error
TableGenerator functions take a string, schema.Table, and io.StringWriter. Implementations will use them to generate SQL for creating or modifying tables
func NewColumnAdder ¶
func NewColumnAdder( a Adapter, options uint8, hasColumn reverse.TableSearcher, ) TableGenerator
NewColumnAdder returns a TableGenerator that adds columns from a schema.Table.
func NewIndexAdder ¶
func NewIndexAdder( a Adapter, options uint8, hasIndex reverse.TableSearcher, ) TableGenerator
NewIndexAdder returns a TableGenerator that adds indices from a schema.Table.
func NewTableAdder ¶
func NewTableAdder( a Adapter, ) TableGenerator
NewTableAdder returns a TableGenerator that adds a table