From f1e66751d5b48bbfb9318737a970d4c366e8152b Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Tue, 12 May 2026 19:56:40 -0400 Subject: [PATCH 1/2] Avoid touching session update time in data migration --- packages/opencode/src/data-migration.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/opencode/src/data-migration.ts b/packages/opencode/src/data-migration.ts index b6956032a4..c1708c84a6 100644 --- a/packages/opencode/src/data-migration.ts +++ b/packages/opencode/src/data-migration.ts @@ -86,18 +86,17 @@ export const layer = Layer.effect( } for (const [sessionID, value] of usageBySession) { - db.update(SessionTable) - .set({ - cost: value.cost, - tokens_input: value.tokens.input, - tokens_output: value.tokens.output, - tokens_reasoning: value.tokens.reasoning, - tokens_cache_read: value.tokens.cache.read, - tokens_cache_write: value.tokens.cache.write, - time_updated: sql`${SessionTable.time_updated}`, - }) - .where(eq(SessionTable.id, sessionID)) - .run() + db.run(sql` + update ${SessionTable} + set + ${SessionTable.cost} = ${value.cost}, + ${SessionTable.tokens_input} = ${value.tokens.input}, + ${SessionTable.tokens_output} = ${value.tokens.output}, + ${SessionTable.tokens_reasoning} = ${value.tokens.reasoning}, + ${SessionTable.tokens_cache_read} = ${value.tokens.cache.read}, + ${SessionTable.tokens_cache_write} = ${value.tokens.cache.write} + where ${SessionTable.id} = ${sessionID} + `) } }), ) From 98aa4623c77a37bfd07d45a5a290498ead4d23d0 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Tue, 12 May 2026 19:58:14 -0400 Subject: [PATCH 2/2] Use Drizzle update for session usage migration --- packages/opencode/src/data-migration.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/opencode/src/data-migration.ts b/packages/opencode/src/data-migration.ts index c1708c84a6..b6956032a4 100644 --- a/packages/opencode/src/data-migration.ts +++ b/packages/opencode/src/data-migration.ts @@ -86,17 +86,18 @@ export const layer = Layer.effect( } for (const [sessionID, value] of usageBySession) { - db.run(sql` - update ${SessionTable} - set - ${SessionTable.cost} = ${value.cost}, - ${SessionTable.tokens_input} = ${value.tokens.input}, - ${SessionTable.tokens_output} = ${value.tokens.output}, - ${SessionTable.tokens_reasoning} = ${value.tokens.reasoning}, - ${SessionTable.tokens_cache_read} = ${value.tokens.cache.read}, - ${SessionTable.tokens_cache_write} = ${value.tokens.cache.write} - where ${SessionTable.id} = ${sessionID} - `) + db.update(SessionTable) + .set({ + cost: value.cost, + tokens_input: value.tokens.input, + tokens_output: value.tokens.output, + tokens_reasoning: value.tokens.reasoning, + tokens_cache_read: value.tokens.cache.read, + tokens_cache_write: value.tokens.cache.write, + time_updated: sql`${SessionTable.time_updated}`, + }) + .where(eq(SessionTable.id, sessionID)) + .run() } }), )