Documentation ¶
Index ¶
- Variables
- func CreateMigration(name, migrationType, dir string, t time.Time) (path string, err error)
- func EnsureDBVersion(conf *DBConf, db *gorm.DB) (int64, error)
- func FinalizeMigration(conf *DBConf, txn *gorm.DB, 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 MigrateFromDir(con *gorm.DB, migrationsDir string) error
- func NumericComponent(name string) (int64, error)
- func OpenDBFromDBConf(conf *DBConf) (*gorm.DB, error)
- func RunMigrations(conf *DBConf, migrationsDir string, target int64) (err error)
- func RunMigrationsOnDb(conf *DBConf, migrationsDir string, target int64, db *gorm.DB) (err error)
- type DBConf
- type DBDriver
- type Migration
- type MigrationRecord
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTableDoesNotExist = errors.New("table does not exist") ErrNoPreviousVersion = errors.New("no previous version found") )
Functions ¶
func CreateMigration ¶
func EnsureDBVersion ¶
EnsureDBVersion retrieve the current version for this DB. Create and initialize the DB version table if it doesn't exist.
func FinalizeMigration ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.