diff --git a/internal/commands/install.go b/internal/commands/install.go index e3fba7c..ad851ab 100644 --- a/internal/commands/install.go +++ b/internal/commands/install.go @@ -4,9 +4,11 @@ import ( "context" "fmt" + "code.destrealm.net/zancarius/justusbot/internal/app" "code.destrealm.net/zancarius/justusbot/internal/models" "code.destrealm.net/zancarius/justusbot/internal/settings" "github.com/urfave/cli/v3" + "go.destrealm.net/embedder" "go.destrealm.net/errors" "go.destrealm.net/logging/v3" "go.destrealm.net/vfs" @@ -27,10 +29,20 @@ func initInstaller(fs vfs.VFS, settings *settings.Settings) (*installer, error) } func (inst *installer) DoInstall(ctx context.Context, cmd *cli.Command) error { - fmt.Println(inst.settings) + // Embedder needs examining. It seems that it doesn't support correctly + // listing directories, possibly due to changes since Golang 1.16. + // + // This code is being added here to support embedded migrations in the + // future. + efs := embedder.NewEmbedderVFS(app.LoadBucket("migrations")) + + lfs := vfs.NewLayeredFS() + lfs.AddFS(efs) + lfs.AddFS(inst.fs) + db := models.OpenDatabase(inst.settings) - fmt.Println(inst.settings.System.DSN) - err := db.Migrate(inst.fs) + fmt.Println("migrated database:", inst.settings.System.DSN) + err := db.Migrate(lfs) if err != nil { inst.logger.Error(errors.Unfurl(err)) }