Log db upgrades

This commit is contained in:
Yiorgis Gozadinos 2025-07-16 18:32:58 +03:00
parent 0bf5606117
commit 4d8088efa8
No known key found for this signature in database
2 changed files with 6 additions and 1 deletions

View file

@ -6,6 +6,7 @@ from typing import Literal
import sqlite_vec
from packaging.version import parse
from rich.console import Console
from haiku.rag.config import Config
from haiku.rag.embeddings import get_embedder
@ -47,6 +48,7 @@ class Store:
# If we have a db already, perform upgrades and return
if self.db_path != ":memory:" and "documents" in existing_tables:
# Upgrade database
console = Console()
db_version = self.get_user_version()
for version, steps in upgrades:
if parse(current_version) >= parse(version) and parse(version) > parse(
@ -54,6 +56,9 @@ class Store:
):
for step in steps:
step(db)
console.print(
f"[green][b]DB Upgrade: [/b]{step.__doc__}[/green]"
)
return
# Create documents table

View file

@ -5,7 +5,7 @@ from haiku.rag.config import Config
def add_settings_table(db: Connection) -> None:
# Create settings table for storing current configuration
"""Create settings table for storing current configuration"""
db.execute("""
CREATE TABLE settings (
id INTEGER PRIMARY KEY DEFAULT 1,