mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-13 15:44:56 +00:00
Use Drizzle update for session usage migration
This commit is contained in:
@@ -86,17 +86,18 @@ export const layer = Layer.effect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const [sessionID, value] of usageBySession) {
|
for (const [sessionID, value] of usageBySession) {
|
||||||
db.run(sql`
|
db.update(SessionTable)
|
||||||
update ${SessionTable}
|
.set({
|
||||||
set
|
cost: value.cost,
|
||||||
${SessionTable.cost} = ${value.cost},
|
tokens_input: value.tokens.input,
|
||||||
${SessionTable.tokens_input} = ${value.tokens.input},
|
tokens_output: value.tokens.output,
|
||||||
${SessionTable.tokens_output} = ${value.tokens.output},
|
tokens_reasoning: value.tokens.reasoning,
|
||||||
${SessionTable.tokens_reasoning} = ${value.tokens.reasoning},
|
tokens_cache_read: value.tokens.cache.read,
|
||||||
${SessionTable.tokens_cache_read} = ${value.tokens.cache.read},
|
tokens_cache_write: value.tokens.cache.write,
|
||||||
${SessionTable.tokens_cache_write} = ${value.tokens.cache.write}
|
time_updated: sql`${SessionTable.time_updated}`,
|
||||||
where ${SessionTable.id} = ${sessionID}
|
})
|
||||||
`)
|
.where(eq(SessionTable.id, sessionID))
|
||||||
|
.run()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user