fix(pg-todos): use pgx.Conn instead of pgxpool.Pool for migrations

pgmigrate.New now requires *pgx.Conn (not *pgxpool.Pool).
The pool is still used for app queries via sqlc/tododb.
This commit is contained in:
AJ ONeal 2026-04-09 13:49:30 -06:00
parent e210295dda
commit 3bc209dc80
No known key found for this signature in database

View File

@ -9,6 +9,7 @@ import (
"os" "os"
"strconv" "strconv"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv" "github.com/joho/godotenv"
@ -71,8 +72,16 @@ func main() {
} }
defer pool.Close() defer pool.Close()
// migrations require a single connection, not a pool
conn, err := pgx.Connect(ctx, pgURL)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: connecting for migrations: %v\n", err)
os.Exit(1)
}
defer func() { _ = conn.Close(ctx) }()
migrations := mustCollectMigrations() migrations := mustCollectMigrations()
runner := pgmigrate.New(pool) runner := pgmigrate.New(conn)
subcmd := args[0] subcmd := args[0]
subArgs := args[1:] subArgs := args[1:]