(dbName string)
| 42 | } |
| 43 | |
| 44 | func ensureDatabase(dbName string) error { |
| 45 | config := util.GetConfig() |
| 46 | databaseType := config.GetString("database/type", "mysql") |
| 47 | databaseConnection := os.Getenv("DATABASE_CONNECTION") |
| 48 | if databaseConnection == "" { |
| 49 | databaseConnection = config.GetString("database/connection", "") |
| 50 | } |
| 51 | db, err := sql.Open(databaseType, databaseConnection) |
| 52 | if err != nil { |
| 53 | return err |
| 54 | } |
| 55 | defer db.Close() |
| 56 | _, err = db.Exec("drop database if exists " + dbName) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | _, err = db.Exec("create database " + dbName) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | return nil |
| 65 | } |
| 66 | |
| 67 | func dropDatabase(dbName string) error { |
| 68 | config := util.GetConfig() |
no test coverage detected