Switch to migrator's new "base" versioning.
This commit is contained in:
parent
1da61079d5
commit
e53f21e814
3 changed files with 26 additions and 6 deletions
|
|
@ -4,11 +4,9 @@ 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/migratory"
|
||||
|
|
@ -35,11 +33,13 @@ func (inst *installer) DoInstall(ctx context.Context, cmd *cli.Command) error {
|
|||
//
|
||||
// This code is being added here to support embedded migrations in the
|
||||
// future.
|
||||
efs := embedder.NewEmbedderVFS(app.LoadBucket("migrations"))
|
||||
/*efs := embedder.NewEmbedderVFS(app.LoadBucket("migrations"))
|
||||
|
||||
lfs := vfs.NewLayeredFS()
|
||||
lfs.AddFS(efs)
|
||||
lfs.AddFS(inst.fs)
|
||||
lfs.AddFS(inst.fs)*/
|
||||
lfs := inst.fs.Clone()
|
||||
_ = lfs.Chdir("migrations/base/sqlite")
|
||||
|
||||
db := models.OpenDatabase(ctx, inst.settings)
|
||||
fmt.Println("migrated database:", inst.settings.System.DSN)
|
||||
|
|
@ -51,7 +51,16 @@ func (inst *installer) DoInstall(ctx context.Context, cmd *cli.Command) error {
|
|||
}
|
||||
|
||||
func (inst *installer) DoUp(ctx context.Context, cmd *cli.Command) error {
|
||||
return inst.DoInstall(ctx, cmd)
|
||||
lfs := inst.fs.Clone()
|
||||
_ = lfs.Chdir("migrations/sqlite")
|
||||
|
||||
db := models.OpenDatabase(ctx, inst.settings)
|
||||
fmt.Println("migrated database:", inst.settings.System.DSN)
|
||||
err := db.Migrate(lfs)
|
||||
if err != nil {
|
||||
inst.logger.Error(errors.Unfurl(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (inst *installer) ListMigrations(ctx context.Context, cmd *cli.Command) error {
|
||||
|
|
|
|||
Loading…
Reference in a new issue