Skip to content

Commit

Permalink
fix(dbmanager): Drop database if you can't connect
Browse files Browse the repository at this point in the history
If you create a database but can't connect to it, clean up after yourself
  • Loading branch information
kyleconroy committed Aug 5, 2024
1 parent 07e96df commit 50804fc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/dbmanager/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (m *ManagedClient) CreateDatabase(ctx context.Context, req *CreateDatabaseR

conn, err := pgx.Connect(ctx, uri.String())
if err != nil {
pool.Exec(ctx, fmt.Sprintf(`DROP DATABASE "%s" IF EXISTS WITH (FORCE)`, name))
return nil, fmt.Errorf("connect %s: %s", name, err)
}
defer conn.Close(ctx)
Expand Down

0 comments on commit 50804fc

Please sign in to comment.