Fixed: create db if not exists

This commit is contained in:
zhenorzz 2024-05-29 15:52:15 +08:00
parent 4d8b3d44c9
commit be4ee57664

View File

@ -187,11 +187,16 @@ func install() {
println("Start to install the database...")
runner, err := model.Open(cfg.DB)
// open connection without database
runner, err := model.Open(config.DBConfig{
Host: cfg.DB.Host, User: cfg.DB.User, Password: cfg.DB.Password, Port: cfg.DB.Port,
})
if err != nil {
panic(err)
}
defer runner.Close()
// create database if not exists
if err := runner.CreateDB(cfg.DB.Database); err != nil {
panic(err)
}