From 9fc6f5207aa0a0e80c01d84259a3818df93f3cb1 Mon Sep 17 00:00:00 2001 From: Przemyslaw Dobrowolski Date: Mon, 27 Mar 2017 16:11:22 +0200 Subject: [PATCH] Add support for adding migrations with custom filenames --- migrate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migrate.go b/migrate.go index 26ce946..b425d07 100644 --- a/migrate.go +++ b/migrate.go @@ -79,6 +79,10 @@ func (ms Migrations) String() string { func AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error) { _, 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) migration := &Migration{Version: v, Next: -1, Previous: -1, UpFn: up, DownFn: down, Source: filename}