fix(api): keep auth sync timestamps monotonic

Use PostgreSQL's clock for both the initial auth sync timestamp and later identity refreshes so host clock skew cannot move the marker backwards.
This commit is contained in:
jjbrunton committed 2026-08-29 23:45:39 +01:00
1 parent 2bc69c2790
commit 266233a473
1 file changed
+4 -1
+4 -1
View File
@@ -83,7 +83,10 @@ export class PostgresRepository implements ApiRepository {
target: profiles.id, target: profiles.id,
set: { set: {
email: sql`coalesce(excluded.email, ${profiles.email})`, email: sql`coalesce(excluded.email, ${profiles.email})`,
authSyncedAt: new Date(), // Keep the write on the same clock as the column default. API and
// PostgreSQL hosts can differ slightly, which must not move this
// monotonic sync marker backwards.
authSyncedAt: sql`now()`,
}, },
}).returning(); }).returning();