MCPcopy Index your code
hub / github.com/apache/answer / CheckDBTableExist

Function CheckDBTableExist

internal/cli/install_check.go:58–82  ·  view source on GitHub ↗

CheckDBTableExist check database whether the table is already exists

(dataConf *data.Database)

Source from the content-addressed store, hash-verified

56
57// CheckDBTableExist check database whether the table is already exists
58func CheckDBTableExist(dataConf *data.Database) bool {
59 db, err := data.NewDB(false, dataConf)
60 if err != nil {
61 fmt.Printf("connection database failed: %s\n", err)
62 return false
63 }
64 defer func() {
65 _ = db.Close()
66 }()
67 if err = db.Ping(); err != nil {
68 fmt.Printf("connection ping database failed: %s\n", err)
69 return false
70 }
71
72 exist, err := db.IsTableExist(&entity.Version{})
73 if err != nil {
74 fmt.Printf("check table exist failed: %s\n", err)
75 return false
76 }
77 if !exist {
78 fmt.Printf("check table not exist\n")
79 return false
80 }
81 return true
82}

Callers 3

CheckConfigFileFunction · 0.92
InitBaseInfoFunction · 0.92
command.goFile · 0.92

Calls 2

NewDBFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected