UNPKG

scai

Version:

> AI-powered CLI tool for commit messages **and** pull request reviews — using local models.

46 lines (42 loc) 1.42 kB
import { getDbForRepo } from "./client.js"; export function initSchema() { const db = getDbForRepo(); db.exec(` -- Create the files table CREATE TABLE IF NOT EXISTS files ( id INTEGER PRIMARY KEY AUTOINCREMENT, path TEXT UNIQUE, filename TEXT, summary TEXT, type TEXT, indexed_at TEXT, last_modified TEXT, embedding TEXT, processing_status TEXT NOT NULL DEFAULT 'unprocessed', functions_extracted_at TEXT ); -- Create the full-text search table, auto-updated via content=files CREATE VIRTUAL TABLE IF NOT EXISTS files_fts USING fts5(filename, summary, path, content='files', content_rowid='id'); `); console.log('✅ SQLite schema initialized with FTS5 auto-sync'); // Create additional tables for functions and function_calls db.exec(` CREATE TABLE IF NOT EXISTS functions ( id INTEGER PRIMARY KEY AUTOINCREMENT, file_id INTEGER REFERENCES files(id), name TEXT, start_line INTEGER, end_line INTEGER, content TEXT, embedding TEXT, lang TEXT ); CREATE INDEX IF NOT EXISTS idx_file_id ON functions(file_id); CREATE TABLE IF NOT EXISTS function_calls ( caller_id INTEGER REFERENCES functions(id), callee_name TEXT ); `); console.log('✅ Schema for functions and function_calls initialized'); }