Make bot types an extension of the bot's kind

Coordinator and worker come from bots.kind; bot_types now only holds
workspace_admin (was admin), each row naming its workspace, with no scope
field. Rows from v0.2.8 and earlier are fixed at boot by migrateBotTypes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-26 06:05:18 +01:00
co-authored by Claude Opus 5.5
parent 657a76d868
commit 926bad6bea
29 changed files with 168 additions and 175 deletions
-20
View File
@@ -1,20 +0,0 @@
import BunSQLite from "@moduletrace/bun-sqlite";
import ensureCoordinatorType from "@/src/functions/backend/db/bot-types/ensure-coordinator-type";
/**
* Safe to run again: gives the coordinator (`kind = 'coordinator'`) its
* install-wide `coordinator` bot type. The super admin's `/admin/bots` does
* the same through `ensureCoordinatorBot`; this is for a headless install.
*
* `bun src/scripts/backfill-bot-types.ts`
*/
async function backfillBotTypes() {
const res = await BunSQLite.sql<{ id: number }>({ sql: `SELECT id FROM bots WHERE kind = 'coordinator'` });
for (const row of res.payload || []) await ensureCoordinatorType({ bot_id: row.id });
console.log(`Checked ${res.payload?.length || 0} coordinator bot types.`);
}
await backfillBotTypes();
process.exit(0);