Skip to content

Commit 695d9a1

Browse files
authored
fix(dbmanager): use correct SQL to drop databases (#3640)
Previously the code used: ``` DROP DATABASE mydb IF EXISTS WITH (FORCE) ``` which is not standard SQL and does not work with PostgreSQL. This patch fixes to code to issue: ``` DROP DATABASE IF EXISTS mydb WITH (FORCE) ```
1 parent acf296d commit 695d9a1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/dbmanager/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (m *ManagedClient) CreateDatabase(ctx context.Context, req *CreateDatabaseR
106106

107107
conn, err := pgx.Connect(ctx, uri.String())
108108
if err != nil {
109-
pool.Exec(ctx, fmt.Sprintf(`DROP DATABASE "%s" IF EXISTS WITH (FORCE)`, name))
109+
pool.Exec(ctx, fmt.Sprintf(`DROP DATABASE IF EXISTS "%s" WITH (FORCE)`, name))
110110
return nil, fmt.Errorf("connect %s: %s", name, err)
111111
}
112112
defer conn.Close(ctx)
@@ -123,7 +123,7 @@ func (m *ManagedClient) CreateDatabase(ctx context.Context, req *CreateDatabaseR
123123
}
124124

125125
if migrationErr != nil {
126-
pool.Exec(ctx, fmt.Sprintf(`DROP DATABASE "%s" IF EXISTS WITH (FORCE)`, name))
126+
pool.Exec(ctx, fmt.Sprintf(`DROP DATABASE IF EXISTS "%s" WITH (FORCE)`, name))
127127
return nil, migrationErr
128128
}
129129

0 commit comments

Comments
 (0)