From 75764a0621c8df6b52301ca6a06db96d472bd177 Mon Sep 17 00:00:00 2001 From: Bryce Plunkett <130488190+bplunkett-stripe@users.noreply.github.com> Date: Thu, 25 Jan 2024 09:46:47 -0800 Subject: [PATCH] Set max connections for plan cmd (#93) --- cmd/pg-schema-diff/plan_cmd.go | 2 ++ pkg/diff/plan_generator.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/pg-schema-diff/plan_cmd.go b/cmd/pg-schema-diff/plan_cmd.go index e465bcb..9ae9c0a 100644 --- a/cmd/pg-schema-diff/plan_cmd.go +++ b/cmd/pg-schema-diff/plan_cmd.go @@ -242,6 +242,8 @@ func generatePlan(ctx context.Context, logger log.Logger, connConfig *pgx.ConnCo } defer connPool.Close() + connPool.SetMaxOpenConns(5) + plan, err := diff.GeneratePlan(ctx, connPool, tempDbFactory, ddl, diff.WithDataPackNewTables(), ) diff --git a/pkg/diff/plan_generator.go b/pkg/diff/plan_generator.go index 987aa45..6b398a2 100644 --- a/pkg/diff/plan_generator.go +++ b/pkg/diff/plan_generator.go @@ -62,7 +62,7 @@ func WithLogger(logger log.Logger) PlanOpt { // // Parameters: // queryable: The target database to generate the diff for. It is recommended to pass in *sql.DB of the db you -// wish to migrate. +// wish to migrate. If using a connection pool, it is RECOMMENDED to set a maximum number of connections. // tempDbFactory: used to create a temporary database instance to extract the schema from the new DDL and validate the // migration plan. It is recommended to use tempdb.NewOnInstanceFactory, or you can provide your own. // newDDL: DDL encoding the new schema