From 8f26723f2f2d075c11779e73ae0d0f96cf102955 Mon Sep 17 00:00:00 2001 From: Jacob Schuurmans Date: Wed, 24 Jul 2024 08:13:09 -0400 Subject: [PATCH] fix for timeouts --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b045fe1..382bc75 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,13 @@ docker-down: docker-clean: @docker-compose -f quickstart.yml down --volumes +## start, and wait for database to be live +crdb-wait: docker-up + @until cockroach sql --insecure -e "select 1" > /dev/null 2>&1; do \ + echo "Waiting for cockroach server to be live..."; \ + sleep 1; \ + done; + ## setup devel database dev-database: | vendor @cockroach sql --insecure -e "drop database if exists fleetdb" @@ -74,7 +81,7 @@ dev-database: | vendor @FLEETDB_CRDB_URI="${DEV_DB}" go run main.go migrate up ## setup test database -test-database: | vendor docker-up +test-database: | vendor crdb-wait @cockroach sql --insecure -e "drop database if exists fleetdb_test" @cockroach sql --insecure -e "create database fleetdb_test" @FLEETDB_CRDB_URI="${TEST_DB}" go run main.go migrate up @@ -91,9 +98,9 @@ install-sqlboiler: go install github.com/volatiletech/sqlboiler/v4@${SQLBOILER} go install github.com/metal-toolbox/sqlboiler-crdb-fleetdb/v4@${SQLBOILER_DRIVER} -## boil sql, if you get this error (server closed the connection), try again. +## boil sql boil: install-sqlboiler test-database - sqlboiler crdb-fleetdb --add-soft-deletes + @sqlboiler crdb-fleetdb --add-soft-deletes ## log into database psql: