From 5bff2a6c9e14763ca8764cf75adba0efbf990e50 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 31 Jul 2026 22:27:58 +0200 Subject: pgruntime: in ConnectForTest, only truncate tables instead of recreating the database DROP + CREATE DATABASE was measured at 100 ms per ConnectForTest(), which is prohibitively slow in large test suites. This should be more in the ballpark of 10 ms per test. --- pgruntime/behavior.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'pgruntime/behavior.go') diff --git a/pgruntime/behavior.go b/pgruntime/behavior.go index 9fb8662..3ffff1e 100644 --- a/pgruntime/behavior.go +++ b/pgruntime/behavior.go @@ -68,8 +68,7 @@ func applyMigrations(ctx context.Context, db gsql.ConnectionHandle, migrations m } // read schema_migrations table - var rowCount int64 - err = queryRow(ctx, db, `SELECT COUNT(*) FROM schema_migrations`, nil, []any{&rowCount}) + rowCount, err := selectOneValue[int64](ctx, db, `SELECT COUNT(*) FROM schema_migrations`) if err != nil { return fmt.Errorf("could not check row count for schema_migrations: %w", err) } -- cgit v1.3.1