fix: install check database add log

This commit is contained in:
LinkinStar 2022-11-10 12:13:42 +08:00
parent 3f5ac0a614
commit 7e11d6b82c
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package cli
import (
"fmt"
"github.com/answerdev/answer/internal/base/data"
"github.com/answerdev/answer/internal/entity"
"github.com/answerdev/answer/pkg/dir"
@ -19,9 +21,11 @@ func CheckUploadDir() bool {
func CheckDB(dataConf *data.Database, mustInstalled bool) bool {
db, err := data.NewDB(false, dataConf)
if err != nil {
fmt.Printf("connection database failed: %s\n", err)
return false
}
if err = db.Ping(); err != nil {
fmt.Printf("connection ping database failed: %s\n", err)
return false
}
if !mustInstalled {
@ -30,9 +34,11 @@ func CheckDB(dataConf *data.Database, mustInstalled bool) bool {
exist, err := db.IsTableExist(&entity.Version{})
if err != nil {
fmt.Printf("check table exist failed: %s\n", err)
return false
}
if !exist {
fmt.Printf("check table not exist\n")
return false
}
return true

View File

@ -35,7 +35,7 @@ func (r *CheckDatabaseReq) GetConnection() string {
}
if r.DbType == string(schemas.POSTGRES) {
host, port := parsePgSQLHostPort(r.DbHost)
return fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s",
return fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
host, port, r.DbUsername, r.DbPassword, r.DbName)
}
return ""