Add support for adding migrations with custom filenames

pull/23/head
Przemyslaw Dobrowolski 2017-03-27 16:11:22 +02:00
parent 221ff41793
commit 9fc6f5207a
1 changed files with 4 additions and 0 deletions

View File

@ -79,6 +79,10 @@ func (ms Migrations) String() string {
func AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error) { func AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error) {
_, filename, _, _ := runtime.Caller(1) _, filename, _, _ := runtime.Caller(1)
AddNamedMigration(filename, up, down)
}
func AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.Tx) error) {
v, _ := NumericComponent(filename) v, _ := NumericComponent(filename)
migration := &Migration{Version: v, Next: -1, Previous: -1, UpFn: up, DownFn: down, Source: filename} migration := &Migration{Version: v, Next: -1, Previous: -1, UpFn: up, DownFn: down, Source: filename}