Documentation ¶
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func CreateMigration(name, migrationType, dir string, t time.Time) (path string, err error)
- func EnsureDBVersion(conf *DBConf, db *sql.DB) (int64, error)
- func FinalizeMigration(conf *DBConf, txn *sql.Tx, direction Direction, v int64) error
- func GetDBVersion(conf *DBConf) (version int64, err error)
- func GetMostRecentDBVersion(dirpath string) (version int64, err error)
- func GetPreviousDBVersion(dirpath string, version int64) (previous int64, err error)
- func MustAsset(name string) []byte
- func NumericComponent(name string) (int64, error)
- func OpenDBFromDBConf(conf *DBConf) (*sql.DB, error)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func RunMigrations(conf *DBConf, migrationsDir string, target int64) (err error)
- func RunMigrationsOnDb(conf *DBConf, migrationsDir string, target int64, db *sql.DB) (err error)
- type DBConf
- type DBDriver
- type Direction
- type Migration
- type MySqlDialect
- type PostgresDialect
- type RedshiftDialect
- type SqlDialect
- type Sqlite3Dialect
Constants ¶
const ( DirectionDown = Direction(false) DirectionUp = Direction(true) )
Variables ¶
var ( ErrTableDoesNotExist = errors.New("table does not exist") ErrNoPreviousVersion = errors.New("no previous version found") )
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func CreateMigration ¶
func EnsureDBVersion ¶
retrieve the current version for this DB. Create and initialize the DB version table if it doesn't exist.
func FinalizeMigration ¶
Update the version table for the given migration, and finalize the transaction.
func GetDBVersion ¶
wrapper for EnsureDBVersion for callers that don't already have their own DB instance
func GetMostRecentDBVersion ¶
helper to identify the most recent possible version within a folder of migration scripts
func GetPreviousDBVersion ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NumericComponent ¶
look for migration scripts with names in the form:
XXX_descriptivename.ext
where XXX specifies the version number and ext specifies the type of migration
func OpenDBFromDBConf ¶
OpenDBFromDBConf wraps database/sql.DB.Open() and configures the newly opened DB based on the given DBConf.
Callers must Close() the returned DB.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func RunMigrations ¶
Types ¶
type DBDriver ¶
type DBDriver struct { Name string OpenStr string Import string Dialect SqlDialect }
DBDriver encapsulates the info needed to work with a specific database driver
type Migration ¶
type Migration struct { Version int64 IsApplied bool TStamp time.Time Source string // path to .go or .sql script }
func CollectMigrations ¶
collect all the valid looking migration scripts in the migrations folder, and key them by version
type MySqlDialect ¶
type MySqlDialect struct{}
type PostgresDialect ¶
type PostgresDialect struct{}
type RedshiftDialect ¶
type RedshiftDialect struct{}
type SqlDialect ¶
type SqlDialect interface {
// contains filtered or unexported methods
}
SqlDialect abstracts the details of specific SQL dialects for goose's few SQL specific statements
type Sqlite3Dialect ¶
type Sqlite3Dialect struct{}