From cb2d1f488a21190068c72a392056787123b6ed89 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Tue, 28 Jun 2022 14:42:19 -0700 Subject: [PATCH] fix: ci uses a migrated DB template (#2696) Signed-off-by: Spike Curtis --- Makefile | 2 +- scripts/migrate-ci/main.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index aeb8971415..3cdc0b1bc2 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ test: test-clean .PHONY: test test-postgres: test-clean test-postgres-docker - DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \ + DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \ -covermode=atomic -coverprofile="gotests.coverage" -timeout=30m \ -coverpkg=./...,github.com/coder/coder/codersdk \ -count=2 -race -failfast diff --git a/scripts/migrate-ci/main.go b/scripts/migrate-ci/main.go index b6cc439e9d..c3bac6c10d 100644 --- a/scripts/migrate-ci/main.go +++ b/scripts/migrate-ci/main.go @@ -27,7 +27,14 @@ func main() { panic(err) } - err = database.MigrateUp(db) + 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 = database.MigrateUp(target) if err != nil { panic(err) }