Skip to content

Commit cb2d1f4

Browse files
authored
fix: ci uses a migrated DB template (#2696)
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent 576aef4 commit cb2d1f4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ test: test-clean
172172
.PHONY: test
173173

174174
test-postgres: test-clean test-postgres-docker
175-
DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \
175+
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \
176176
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m \
177177
-coverpkg=./...,github.com/coder/coder/codersdk \
178178
-count=2 -race -failfast

scripts/migrate-ci/main.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ func main() {
2727
panic(err)
2828
}
2929

30-
err = database.MigrateUp(db)
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 = database.MigrateUp(target)
3138
if err != nil {
3239
panic(err)
3340
}

0 commit comments

Comments
 (0)