feat: add database schema with WAL mode and FTS5 triggers

SQLite database layer with thread-local connections, WAL journal mode,
foreign key enforcement, and FTS5 full-text search on utterances via
content-table triggers. TDD: 5 tests written first, all passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 10:28:05 -05:00
parent d95fa30017
commit 052f019075
3 changed files with 168 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import pytest
import os
from app.shared.config import Settings
from app.shared.database import init_schema, get_db
@pytest.fixture
def settings(tmp_path):
db_file = str(tmp_path / "test.db")
clips_dir = str(tmp_path / "clips")
os.makedirs(clips_dir, exist_ok=True)
s = Settings(
db_path=db_file,
clips_dir=clips_dir,
speaches_url="http://localhost:9999",
ollama_url="http://localhost:9999",
livekit_api_key="test",
livekit_api_secret="test",
)
init_schema(s)
return s
@pytest.fixture
def db(settings):
return get_db(settings)
# Add to conftest.py
from app.shared import database as _db_module
@pytest.fixture(autouse=True)
def reset_db_connection():
"""Reset thread-local DB connection between tests."""
_db_module._local.conn = None
yield
if hasattr(_db_module._local, 'conn') and _db_module._local.conn:
_db_module._local.conn.close()
_db_module._local.conn = None