From 72cb2d3f43810a5957d5e4c142b3dbc01ac9ae45 Mon Sep 17 00:00:00 2001 From: egor-romanov <58992960+egor-romanov@users.noreply.github.com> Date: Sun, 10 Jul 2022 14:40:51 +0300 Subject: [PATCH] [#53] fix migrations register in framework mode --- migrations/1640988000_init.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/migrations/1640988000_init.go b/migrations/1640988000_init.go index 0c0999f2..8ee07ad6 100644 --- a/migrations/1640988000_init.go +++ b/migrations/1640988000_init.go @@ -3,6 +3,8 @@ package migrations import ( "fmt" + "path/filepath" + "runtime" "github.com/pocketbase/dbx" "github.com/pocketbase/pocketbase/daos" @@ -20,7 +22,14 @@ func Register( down func(db dbx.Builder) error, optFilename ...string, ) { - AppMigrations.Register(up, down, optFilename...) + var optFiles []string + if len(optFilename) > 0 { + optFiles = optFilename + } else { + _, path, _, _ := runtime.Caller(1) + optFiles = append(optFiles, filepath.Base(path)) + } + AppMigrations.Register(up, down, optFiles...) } func init() {