feat: schema v2 migration, database performance, batch query methods
- Add provenance column on edges for tracking how edges were created - Add project_metadata table for version/provenance tracking - Make unresolved_refs file_path/language NOT NULL with defaults - Add composite indexes for unresolved_refs and edges.provenance - Update v2 migration to handle all new schema additions - Record schema version on initialize to prevent re-migration - Add dynamic prepared statement cache (getDynamicStmt) for varying SQL - Add batch methods: getNodesByIds, getNodesByKinds, getFileHashMap, getFileSyncMap - Add project metadata methods: getMetadata, setMetadata, getAllMetadata - Optimize getStats to use single aggregate query - Optimize getStaleFiles to use temporary table JOIN - Add provenance parameter to getOutgoingEdges - Add intent field to SearchOptions type
This commit is contained in:
@@ -52,6 +52,14 @@ export class DatabaseConnection {
|
||||
const schema = fs.readFileSync(schemaPath, 'utf-8');
|
||||
db.exec(schema);
|
||||
|
||||
// Record current schema version so migrations aren't re-applied on open
|
||||
const currentVersion = getCurrentVersion(db);
|
||||
if (currentVersion < CURRENT_SCHEMA_VERSION) {
|
||||
db.prepare(
|
||||
'INSERT OR IGNORE INTO schema_versions (version, applied_at, description) VALUES (?, ?, ?)'
|
||||
).run(CURRENT_SCHEMA_VERSION, Date.now(), 'Initial schema includes all migrations');
|
||||
}
|
||||
|
||||
return new DatabaseConnection(db, dbPath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user