mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
fix(coach): keep updatedAt through storage-only rewrites
The title encryption backfill moved each Coach conversation's title into ciphertext with a plain Prisma update, which stamps updatedAt. The Coach panel orders and groups conversations by that column, so threads untouched for months showed up under Today. The memory summary refresh did the same in the background. Storage-only rewrites now carry the row's own updatedAt and match on it, so a turn that lands meanwhile wins and the row is retried on the next pass: conversation titles, practitioner contacts, measurement and mood notes (where updatedAt is the sync cursor), inventory notes, and the mood-note script. The summary refresh writes through raw SQL. A guard freezes both rules: every backfill write on a model with @updatedAt names the column or is listed with the reason the stamp is wanted, and every conversation write outside the person's own actions keeps it.
This commit is contained in:
1 parent
3381026acb
commit
7d42cf7122
13 files changed
+504
-77
No files matched your search
@@ -52,6 +52,7 @@ interface RowSnapshot {
|
||||
id: string;
|
||||
tags: string | null;
|
||||
note: string | null;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
@@ -74,7 +75,7 @@ async function main(): Promise<void> {
|
||||
tags: { not: null },
|
||||
note: null,
|
||||
},
|
||||
select: { id: true, tags: true, note: true },
|
||||
select: { id: true, tags: true, note: true, updatedAt: true },
|
||||
});
|
||||
|
||||
console.log(`[backfill-note] scanned ${candidates.length} candidate rows`);
|
||||
@@ -87,9 +88,11 @@ async function main(): Promise<void> {
|
||||
|
||||
updated += 1;
|
||||
if (!dryRun) {
|
||||
// The entry did not change for its reader; it keeps its `updatedAt`
|
||||
// (the sync cursor) rather than taking the script's run time.
|
||||
await prisma.moodEntry.update({
|
||||
where: { id: row.id },
|
||||
data: { note, tags: newTags },
|
||||
data: { note, tags: newTags, updatedAt: row.updatedAt },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user