fix(db): log which indexes the migration actually created

This commit is contained in:
jamiepine
2026-10-04 00:00:41 +00:00
committed by capy-ai-staging[bot]
parent 22a3f6b3dd
commit dd1ada8239
+10 -1
View File
@@ -321,8 +321,13 @@ def _migrate_add_indexes(engine, tables: set[str]) -> None:
] ]
with engine.connect() as conn: with engine.connect() as conn:
existing = {
row[0]
for row in conn.execute(text("SELECT name FROM sqlite_master WHERE type = 'index'"))
}
created = []
for index_name, table, column in indexes: for index_name, table, column in indexes:
if table not in tables: if table not in tables or index_name in existing:
continue continue
conn.execute( conn.execute(
text( text(
@@ -330,8 +335,12 @@ def _migrate_add_indexes(engine, tables: set[str]) -> None:
f" ON {table} ({column})" f" ON {table} ({column})"
) )
) )
created.append(index_name)
conn.commit() conn.commit()
if created:
logger.info("Created %d missing index(es): %s", len(created), ", ".join(created))
def _normalize_storage_paths(engine, tables: set[str]) -> None: def _normalize_storage_paths(engine, tables: set[str]) -> None:
"""Normalize stored file paths to be relative to the configured data dir.""" """Normalize stored file paths to be relative to the configured data dir."""