Documentation ¶
Index ¶
- Variables
- 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 bool, 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 NumericComponent(name string) (int64, error)
- func OpenDBFromDBConf(conf *DBConf) (*sql.DB, 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 Migration
- type MigrationRecord
- type MySqlDialect
- type PostgresDialect
- type SqlDialect
- type Sqlite3Dialect
Constants ¶
This section is empty.
Variables ¶
var ( ErrTableDoesNotExist = errors.New("table does not exist") ErrNoPreviousVersion = errors.New("no previous version found") )
Functions ¶
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 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 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 MigrationRecord ¶
type MySqlDialect ¶
type MySqlDialect struct{}
type PostgresDialect ¶
type PostgresDialect 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{}