mirror of
https://github.com/therootcompany/golib.git
synced 2026-11-04 06:55:00 +00:00
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:
parent
e210295dda
commit
3bc209dc80
@ -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:]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user