From 21f78f772130f360483f4c948a1ebfb8d4213721 Mon Sep 17 00:00:00 2001 From: kenneth Date: Mon, 16 Mar 2026 01:24:24 +0000 Subject: [PATCH] fix(backend): set updatedAt explicitly in all mutations onConflictDoUpdate bypasses Drizzle's $onUpdate hook. Set updatedAt explicitly in all mutation methods. Co-authored-by: Ona --- apps/aelis-backend/src/sources/user-sources.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/aelis-backend/src/sources/user-sources.ts b/apps/aelis-backend/src/sources/user-sources.ts index 5bbc810..0426908 100644 --- a/apps/aelis-backend/src/sources/user-sources.ts +++ b/apps/aelis-backend/src/sources/user-sources.ts @@ -30,7 +30,7 @@ export function sources(db: Database, userId: string) { async enableSource(sourceId: string) { const rows = await db .update(userSources) - .set({ enabled: true }) + .set({ enabled: true, updatedAt: new Date() }) .where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId))) .returning({ id: userSources.id }) @@ -43,7 +43,7 @@ export function sources(db: Database, userId: string) { async disableSource(sourceId: string) { const rows = await db .update(userSources) - .set({ enabled: false }) + .set({ enabled: false, updatedAt: new Date() }) .where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId))) .returning({ id: userSources.id }) @@ -59,7 +59,7 @@ export function sources(db: Database, userId: string) { .values({ userId, sourceId, config }) .onConflictDoUpdate({ target: [userSources.userId, userSources.sourceId], - set: { config }, + set: { config, updatedAt: new Date() }, }) }, @@ -67,7 +67,7 @@ export function sources(db: Database, userId: string) { async updateCredentials(sourceId: string, credentials: Buffer) { const rows = await db .update(userSources) - .set({ credentials }) + .set({ credentials, updatedAt: new Date() }) .where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId))) .returning({ id: userSources.id })