chore: add db switch back but with comments

Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
izzy
2026-01-29 16:10:52 +00:00
parent 9208512648
commit ab2036f289

View File

@@ -230,10 +230,14 @@ const SQL_RESET_SCHEMA = (username: string) => `
async function* sql(inputStream: Readable, databaseUsername: string, isPgClusterDump: boolean) {
yield SQL_DROP_CONNECTIONS;
if (!isPgClusterDump) {
yield SQL_RESET_SCHEMA(databaseUsername);
}
yield isPgClusterDump
? // it is likely the dump contains SQL to try to drop the currently active
// database to ensure we have a fresh slate; if the `postgres` database exists
// then prefer to switch before continuing otherwise this will just silently fail
String.raw`
\c postgres
`
: SQL_RESET_SCHEMA(databaseUsername);
for await (const chunk of inputStream) {
yield chunk;