2026-10-08 15:38:12 -06:00
|
|
|
package commands
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"code.destrealm.net/zancarius/justusbot/internal/models"
|
|
|
|
|
"code.destrealm.net/zancarius/justusbot/internal/settings"
|
|
|
|
|
"github.com/urfave/cli/v3"
|
|
|
|
|
"go.destrealm.net/errors"
|
|
|
|
|
"go.destrealm.net/logging/v3"
|
|
|
|
|
"go.destrealm.net/vfs"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type installer struct {
|
|
|
|
|
fs vfs.VFS
|
|
|
|
|
logger *logging.Log
|
|
|
|
|
settings *settings.Settings
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func initInstaller(fs vfs.VFS, settings *settings.Settings) (*installer, error) {
|
|
|
|
|
return &installer{
|
|
|
|
|
fs,
|
|
|
|
|
logging.Get("initializer"),
|
|
|
|
|
settings,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (inst *installer) DoInstall(ctx context.Context, cmd *cli.Command) error {
|
|
|
|
|
fmt.Println(inst.settings)
|
2026-10-12 20:48:09 -06:00
|
|
|
db := models.OpenDatabase(inst.settings)
|
2026-10-08 15:38:12 -06:00
|
|
|
fmt.Println(inst.settings.System.DSN)
|
|
|
|
|
err := db.Migrate(inst.fs)
|
|
|
|
|
if err != nil {
|
|
|
|
|
inst.logger.Error(errors.Unfurl(err))
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|