feat(backend): migration to retire openai_direct runtime
This commit is contained in:
@@ -23,3 +23,35 @@ export const backfillAutoSyncDefaults = internalMutation({
|
||||
return { updated };
|
||||
},
|
||||
});
|
||||
|
||||
// One-shot migration retiring the legacy `openai_direct` runtime literal:
|
||||
// rewrites any surviving `agentJobs`/`spoonAgentSettings` rows to `opencode`.
|
||||
// `openai_direct` stays in the schema unions as a legacy-read literal; nothing
|
||||
// writes it anymore. Run once post-deploy via
|
||||
// `npx convex run migrations:migrateOpenAiDirectRuntime`. Idempotent.
|
||||
export const migrateOpenAiDirectRuntime = internalMutation({
|
||||
args: {},
|
||||
returns: v.object({ patched: v.number() }),
|
||||
handler: async (ctx) => {
|
||||
let patched = 0;
|
||||
for (const job of await ctx.db.query('agentJobs').collect()) {
|
||||
if (job.runtime === 'openai_direct') {
|
||||
await ctx.db.patch(job._id, {
|
||||
runtime: 'opencode',
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
patched += 1;
|
||||
}
|
||||
}
|
||||
for (const settings of await ctx.db.query('spoonAgentSettings').collect()) {
|
||||
if (settings.runtime === 'openai_direct') {
|
||||
await ctx.db.patch(settings._id, {
|
||||
runtime: 'opencode',
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
patched += 1;
|
||||
}
|
||||
}
|
||||
return { patched };
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user