MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / applyLegacyChain

Function applyLegacyChain

apps/local/src/db/v1-v2-ledger.test.ts:69–92  ·  view source on GitHub ↗
(dbPath: string, upToIdx?: number)

Source from the content-addressed store, hash-verified

67 * database carries genuine drizzle hashes — exactly what a real pre-v1.5
68 * release produced. */
69const applyLegacyChain = async (dbPath: string, upToIdx?: number): Promise<void> => {
70 let folder = legacyDir;
71 if (upToIdx !== undefined) {
72 folder = join(workDir, `legacy-upto-${upToIdx}`);
73 mkdirSync(join(folder, "meta"), { recursive: true });
74 const journal = decodeJournal(
75 readFileSync(join(legacyDir, "meta", "_journal.json")).toString(),
76 );
77 const kept = journal.entries.filter((entry) => entry.idx <= upToIdx);
78 for (const entry of kept) {
79 writeFileSync(
80 join(folder, `${entry.tag}.sql`),
81 readFileSync(join(legacyDir, `${entry.tag}.sql`)),
82 );
83 }
84 writeFileSync(
85 join(folder, "meta", "_journal.json"),
86 JSON.stringify({ ...journal, entries: kept }),
87 );
88 }
89 const client = await openLocalLibsql(dbPath);
90 await migrate(drizzle({ client }), { migrationsFolder: folder });
91 client.close();
92};
93
94/** Seed one mcp source row (the minimal real v1 content the planner maps to
95 * an integration). */

Callers 1

Calls 4

openLocalLibsqlFunction · 0.90
toStringMethod · 0.80
decodeJournalFunction · 0.70
closeMethod · 0.65

Tested by

no test coverage detected