MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / pendingV16

Function pendingV16

__tests__/migration-concurrent-opens.test.ts:96–115  ·  view source on GitHub ↗

Take the index back to version 15, the way an index built before migration 16 is.

(refs = 0)

Source from the content-addressed store, hash-verified

94
95 /** Take the index back to version 15, the way an index built before migration 16 is. */
96 function pendingV16(refs = 0): void {
97 const { db } = createDatabase(dbPath);
98 try {
99 db.exec('PRAGMA foreign_keys = OFF');
100 db.exec(`DROP INDEX IF EXISTS ${V16_INDEX};
101 DELETE FROM schema_versions WHERE version >= 16;
102 INSERT OR IGNORE INTO schema_versions (version, applied_at, description) VALUES (15, 0, 'fixture');`);
103 if (refs > 0) {
104 // Enough rows that building the index takes a while, so openers overlap.
105 db.exec(`WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < ${refs})
106 INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, col, file_path, language, status, name_tail)
107 SELECT 'n' || (i % 500), 'store.get' || i, 'calls', i % 900, 1, 'src/f' || (i % 300) || '.ts', 'typescript',
108 CASE WHEN i % 3 = 0 THEN 'failed' ELSE 'pending' END,
109 CASE WHEN i % 3 = 0 THEN 'module:./m' || (i % 50) ELSE 'get' || i END
110 FROM n`);
111 }
112 } finally {
113 db.close();
114 }
115 }
116
117 function state(): { version: number; v16Records: number; index: boolean } {
118 const { db } = createDatabase(dbPath, { readOnly: true });

Calls 3

createDatabaseFunction · 0.90
execMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected