Documentation ¶
Overview ¶
Package driver holds the driver interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExtension ¶
FileExtension returns extension of migration file for given driver. Panics if you provide instance of unregistered driver.
func FileTemplate ¶
FileTemplate returns initial content of migration file for given driver. Panics if you provide instance of unregistered driver.
func Register ¶
func Register(driverName, migrationFileExtension string, migrationFileTemplate []byte, f FactoryFunc)
Register a driver so it can be created from its name. Drivers should call this from an init() function so that they registers themselves on import. filenameExtension returns the extension of the migration files. migrationFileTemplate is a content that should be written into newly-created migration file (can be nil).
Types ¶
type Driver ¶
type Driver interface { // Close is the last function to be called. // Close any open connection here. Close() error // Migrate is the heart of the driver. // It will receive a file which the driver should apply // to its backend or whatever. The migration function should use // the pipe channel to return any errors or other useful information. Migrate(file file.File) error // Version returns the current migration version. Version() (file.Version, error) // Versions returns the list of applied migrations. Versions() (file.Versions, error) // Execute a statement Execute(statement string) error }
Driver is the interface type that needs to implemented by all drivers.
type FactoryFunc ¶
FactoryFunc produces driver instances