Files
coder/scripts/migrate-ci/main.go
Kyle Carberry 22e781eced chore: add /v2 to import module path (#9072)
* chore: add /v2 to import module path

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```

Migrate generated files to import /v2

* Fix gen
2023-08-18 18:55:43 +00:00

44 lines
832 B
Go

package main
import (
"database/sql"
"fmt"
"github.com/coder/coder/v2/coderd/database/migrations"
"github.com/coder/coder/v2/cryptorand"
)
func main() {
dbURL := "postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable"
db, err := sql.Open("postgres", dbURL)
if err != nil {
panic(err)
}
defer db.Close()
dbName, err := cryptorand.StringCharset(cryptorand.Lower, 10)
if err != nil {
panic(err)
}
dbName = "ci" + dbName
_, err = db.Exec("CREATE DATABASE " + dbName)
if err != nil {
panic(err)
}
targetURL := fmt.Sprintf("postgres://postgres:postgres@127.0.0.1:5432/%s?sslmode=disable", dbName)
target, err := sql.Open("postgres", targetURL)
if err != nil {
panic(err)
}
defer target.Close()
err = migrations.Up(target)
if err != nil {
panic(err)
}
_, _ = fmt.Println(dbName)
}