mirror of https://gitee.com/answerdev/answer.git
fix: install check database add log
This commit is contained in:
parent
3f5ac0a614
commit
7e11d6b82c
|
@ -1,6 +1,8 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/answerdev/answer/internal/base/data"
|
"github.com/answerdev/answer/internal/base/data"
|
||||||
"github.com/answerdev/answer/internal/entity"
|
"github.com/answerdev/answer/internal/entity"
|
||||||
"github.com/answerdev/answer/pkg/dir"
|
"github.com/answerdev/answer/pkg/dir"
|
||||||
|
@ -19,9 +21,11 @@ func CheckUploadDir() bool {
|
||||||
func CheckDB(dataConf *data.Database, mustInstalled bool) bool {
|
func CheckDB(dataConf *data.Database, mustInstalled bool) bool {
|
||||||
db, err := data.NewDB(false, dataConf)
|
db, err := data.NewDB(false, dataConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("connection database failed: %s\n", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if err = db.Ping(); err != nil {
|
if err = db.Ping(); err != nil {
|
||||||
|
fmt.Printf("connection ping database failed: %s\n", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !mustInstalled {
|
if !mustInstalled {
|
||||||
|
@ -30,9 +34,11 @@ func CheckDB(dataConf *data.Database, mustInstalled bool) bool {
|
||||||
|
|
||||||
exist, err := db.IsTableExist(&entity.Version{})
|
exist, err := db.IsTableExist(&entity.Version{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("check table exist failed: %s\n", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !exist {
|
if !exist {
|
||||||
|
fmt.Printf("check table not exist\n")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (r *CheckDatabaseReq) GetConnection() string {
|
||||||
}
|
}
|
||||||
if r.DbType == string(schemas.POSTGRES) {
|
if r.DbType == string(schemas.POSTGRES) {
|
||||||
host, port := parsePgSQLHostPort(r.DbHost)
|
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)
|
host, port, r.DbUsername, r.DbPassword, r.DbName)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Reference in New Issue