MCPcopy
hub / github.com/BuilderIO/agent-native / ensureToolDataItemId

Function ensureToolDataItemId

packages/core/src/tools/store.ts:87–111  ·  view source on GitHub ↗
(
  client: ReturnType<typeof getDbExec>,
  pg: boolean,
)

Source from the content-addressed store, hash-verified

85}
86
87async function ensureToolDataItemId(
88 client: ReturnType<typeof getDbExec>,
89 pg: boolean,
90): Promise<void> {
91 if (pg) {
92 await client.execute(
93 `ALTER TABLE tool_data ADD COLUMN IF NOT EXISTS item_id TEXT`,
94 );
95 return;
96 }
97
98 // Keep this additive: legacy rows with item_id=id are still read correctly
99 // through COALESCE(item_id, id), so SQLite never needs a table rebuild here.
100 try {
101 await client.execute(`ALTER TABLE tool_data ADD COLUMN item_id TEXT`);
102 } catch (err: any) {
103 if (
104 !String(err?.message ?? err)
105 .toLowerCase()
106 .includes("duplicate")
107 ) {
108 throw err;
109 }
110 }
111}
112
113async function ensureToolDataScope(
114 client: ReturnType<typeof getDbExec>,

Callers 1

ensureToolsTablesFunction · 0.85

Calls 1

executeMethod · 0.65

Tested by

no test coverage detected