func NewPostgresSchemaString(t *testing.T, sql string, opts ...Option) (*pgx.Conn, CleanupFunc) {
	t.Helper()
	connStr := "user=postgres password=hunter2 host=localhost port=5555 dbname=pggen"
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	conn, err := pgx.Connect(ctx, connStr)
	if err != nil {
		t.Fatalf("connect to docker postgres: %s", err)
	}
	schema := "pggen_test_" + strconv.Itoa(int(rand.Int31()))
	if _, err = conn.Exec(ctx, "CREATE SCHEMA "+schema); err != nil {
		t.Fatalf("create new schema: %s", err)
	}
	t.Logf("created schema: %s", schema)
	connStr += " search_path=" + schema
	connCfg, err := pgx.ParseConfig(connStr)
	if err != nil {
		t.Fatalf("parse config: %q: %s", connStr, err)
	}
	for _, opt := range opts {
		opt(connCfg)
	}
	schemaConn, err := pgx.ConnectConfig(ctx, connCfg)
	if err != nil {
		t.Fatalf("connect to docker postgres with search path: %s", err)
	}
	if _, err := schemaConn.Exec(ctx, sql); err != nil {
		t.Fatalf("run sql: %s", err)
	}
	cleanup := func() {
		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
		defer cancel()
		if _, err := conn.Exec(ctx, "DROP SCHEMA "+schema+" CASCADE"); err != nil {
			t.Errorf("close conn: %s", err)
		}
		if err := conn.Close(ctx); err != nil {
			t.Errorf("close conn: %s", err)
		}
		if err = schemaConn.Close(ctx); err != nil {
			t.Errorf("close schema conn: %s", err)
		}
	}
	return schemaConn, cleanup
}
NewPostgresSchema opens a connection with search_path set to a randomly
named, new schema and loads the sql string.
package pgtest
import (
	"context"
	crand "crypto/rand"
	"encoding/binary"
	"github.com/jackc/pgx/v4"
	"io/ioutil"
	"math/rand"
	"strconv"
	"strings"
	"testing"
	"time"
)
func init() {
	var rngSeed int64
	_ = binary.Read(crand.Reader, binary.LittleEndian, &rngSeed)
	rand.Seed(rngSeed)
}
type CleanupFunc func()
type Option func(config *pgx.ConnConfig)