[#53] fix migrations register in framework mode

This commit is contained in:
egor-romanov 2022-07-10 14:40:51 +03:00 committed by GitHub
parent 0739e90ff2
commit 72cb2d3f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package migrations
import ( import (
"fmt" "fmt"
"path/filepath"
"runtime"
"github.com/pocketbase/dbx" "github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos" "github.com/pocketbase/pocketbase/daos"
@ -20,7 +22,14 @@ func Register(
down func(db dbx.Builder) error, down func(db dbx.Builder) error,
optFilename ...string, 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() { func init() {