Skip to content

Commit

Permalink
[pocketbase#53] fix migrations register in framework mode
Browse files Browse the repository at this point in the history
  • Loading branch information
egor-romanov authored Jul 10, 2022
1 parent 0739e90 commit 72cb2d3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion migrations/1640988000_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package migrations

import (
"fmt"
"path/filepath"
"runtime"

"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
Expand All @@ -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() {
Expand Down

0 comments on commit 72cb2d3

Please sign in to comment.