From 3fc3d19cd012649569d8141d949b6114875fcf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Gr=C3=BCneberg?= Date: Mon, 24 Nov 2025 19:37:48 +0800 Subject: [PATCH] chore: add app name for postgres connection --- .../orb-sync-lib/src/database/postgres.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/orb-sync-lib/src/database/postgres.ts b/packages/orb-sync-lib/src/database/postgres.ts index 1ea374b..7c33c0a 100644 --- a/packages/orb-sync-lib/src/database/postgres.ts +++ b/packages/orb-sync-lib/src/database/postgres.ts @@ -11,7 +11,12 @@ export class PostgresClient { pool: pg.Pool; constructor(private config: PostgresConfig) { - this.pool = new pg.Pool({ connectionString: config.databaseUrl, max: 25, keepAlive: true }); + this.pool = new pg.Pool({ + connectionString: config.databaseUrl, + max: 25, + keepAlive: true, + application_name: 'orb-sync-engine', + }); } async upsertMany< @@ -51,12 +56,7 @@ export class PostgresClient { T extends { [Key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any }, - >( - entries: T[], - table: string, - tableSchema: JsonSchema, - syncTimestamp: string - ): Promise { + >(entries: T[], table: string, tableSchema: JsonSchema, syncTimestamp: string): Promise { if (!entries.length) return []; // Max 5 in parallel to avoid exhausting connection pool @@ -72,12 +72,8 @@ export class PostgresClient { const cleansed = this.cleanseArrayField(entry, tableSchema); // Add last_synced_at to the cleansed data for SQL parameter binding cleansed.last_synced_at = syncTimestamp; - - const upsertSql = this.constructUpsertWithTimestampProtectionSql( - this.config.schema, - table, - tableSchema - ); + + const upsertSql = this.constructUpsertWithTimestampProtectionSql(this.config.schema, table, tableSchema); const prepared = sql(upsertSql, { useNullForMissing: true,