Skip to content

The open-source app everyone uses to manage agents at work

[codex] Harden non-system database backup schemas (#4960)

Dottad7719423e90b
diff --git a/packages/db/src/backup-lib.ts b/packages/db/src/backup-lib.ts
index 4fb8d4fabc..2ae92517d5 100644
--- a/packages/db/src/backup-lib.ts
+++ b/packages/db/src/backup-lib.ts
@@ -239,9 +239,9 @@ function tableKey(schemaName: string, tableName: string): string {
}
function nonSystemSchemaPredicate(identifier: string): string {
- return `${identifier} NOT IN ('pg_catalog', 'information_schema')
- AND ${identifier} NOT LIKE 'pg_toast%'
- AND ${identifier} NOT LIKE 'pg_temp_%'`;
+ // PostgreSQL reserves pg_ prefixes for system schemas, including temp/toast variants.
+ return `${identifier} <> 'information_schema'
+ AND ${identifier} NOT LIKE 'pg\\_%' ESCAPE '\\'`;
}
function hasBackupTransforms(opts: RunDatabaseBackupOptions): boolean {