MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / create_v1_schema

Function create_v1_schema

tests/storage_suite/migration_test.rs:297–393  ·  view source on GitHub ↗

Creates the V1 schema (tables, FTS, indexes — no metadata, no complexity columns).

(conn: &Connection)

Source from the content-addressed store, hash-verified

295
296/// Creates the V1 schema (tables, FTS, indexes — no metadata, no complexity columns).
297async fn create_v1_schema(conn: &Connection) {
298 conn.execute_batch(
299 "CREATE TABLE IF NOT EXISTS nodes (
300 id TEXT PRIMARY KEY,
301 kind TEXT NOT NULL,
302 name TEXT NOT NULL,
303 qualified_name TEXT NOT NULL,
304 file_path TEXT NOT NULL,
305 start_line INTEGER NOT NULL,
306 end_line INTEGER NOT NULL,
307 start_column INTEGER NOT NULL,
308 end_column INTEGER NOT NULL,
309 docstring TEXT,
310 signature TEXT,
311 visibility TEXT NOT NULL DEFAULT 'private',
312 is_async INTEGER NOT NULL DEFAULT 0,
313 updated_at INTEGER NOT NULL
314 );
315
316 CREATE TABLE IF NOT EXISTS edges (
317 id INTEGER PRIMARY KEY AUTOINCREMENT,
318 source TEXT NOT NULL,
319 target TEXT NOT NULL,
320 kind TEXT NOT NULL,
321 line INTEGER,
322 FOREIGN KEY (source) REFERENCES nodes(id) ON DELETE CASCADE,
323 FOREIGN KEY (target) REFERENCES nodes(id) ON DELETE CASCADE
324 );
325
326 CREATE TABLE IF NOT EXISTS files (
327 path TEXT PRIMARY KEY,
328 content_hash TEXT NOT NULL,
329 size INTEGER NOT NULL,
330 modified_at INTEGER NOT NULL,
331 indexed_at INTEGER NOT NULL,
332 node_count INTEGER NOT NULL DEFAULT 0
333 );
334
335 CREATE TABLE IF NOT EXISTS unresolved_refs (
336 id INTEGER PRIMARY KEY AUTOINCREMENT,
337 from_node_id TEXT NOT NULL,
338 reference_name TEXT NOT NULL,
339 reference_kind TEXT NOT NULL,
340 line INTEGER NOT NULL,
341 col INTEGER NOT NULL,
342 file_path TEXT NOT NULL,
343 FOREIGN KEY (from_node_id) REFERENCES nodes(id) ON DELETE CASCADE
344 );
345
346 CREATE TABLE IF NOT EXISTS vectors (
347 node_id TEXT PRIMARY KEY,
348 embedding BLOB NOT NULL,
349 model TEXT NOT NULL,
350 created_at INTEGER NOT NULL,
351 FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
352 );
353
354 CREATE VIRTUAL TABLE IF NOT EXISTS nodes_fts USING fts5(

Callers 6

test_migrate_from_v1Function · 0.85
test_migrate_from_v2Function · 0.85
test_migrate_from_v3Function · 0.85
test_migrate_from_v4Function · 0.85

Calls 1

set_user_versionFunction · 0.70

Tested by

no test coverage detected