CheckDBTableExist check database whether the table is already exists
(dataConf *data.Database)
| 56 | |
| 57 | // CheckDBTableExist check database whether the table is already exists |
| 58 | func 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 | } |
no test coverage detected