()
| 9 | ) |
| 10 | |
| 11 | func main() { |
| 12 | dbURL := "postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable" |
| 13 | db, err := sql.Open("postgres", dbURL) |
| 14 | if err != nil { |
| 15 | panic(err) |
| 16 | } |
| 17 | defer db.Close() |
| 18 | |
| 19 | dbName, err := cryptorand.StringCharset(cryptorand.Lower, 10) |
| 20 | if err != nil { |
| 21 | panic(err) |
| 22 | } |
| 23 | |
| 24 | dbName = "ci" + dbName |
| 25 | _, err = db.Exec("CREATE DATABASE " + dbName) |
| 26 | if err != nil { |
| 27 | panic(err) |
| 28 | } |
| 29 | |
| 30 | targetURL := fmt.Sprintf("postgres://postgres:postgres@127.0.0.1:5432/%s?sslmode=disable", dbName) |
| 31 | target, err := sql.Open("postgres", targetURL) |
| 32 | if err != nil { |
| 33 | panic(err) |
| 34 | } |
| 35 | defer target.Close() |
| 36 | |
| 37 | err = migrations.Up(target) |
| 38 | if err != nil { |
| 39 | panic(err) |
| 40 | } |
| 41 | |
| 42 | _, _ = fmt.Println(dbName) |
| 43 | } |
nothing calls this directly
no test coverage detected