Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(persistence): ignore pgvector type warning in schema reconcile (#3157)

atharvab19021072f207e4a7
diff --git a/packages/core/src/repowise/core/persistence/database.py b/packages/core/src/repowise/core/persistence/database.py
index fcdd55d6b..4a8e4065d 100644
--- a/packages/core/src/repowise/core/persistence/database.py
+++ b/packages/core/src/repowise/core/persistence/database.py
@@ -13,6 +13,7 @@ from __future__ import annotations
import os
import sqlite3
+import warnings
from collections.abc import AsyncGenerator, Callable
from contextlib import asynccontextmanager
from pathlib import Path
@@ -607,7 +608,11 @@ def _reconcile_schema(connection: object) -> None:
# nullability. We deliberately do NOT enforce FK constraints on
# back-filled columns: SQLite can't add an enforced FK after the
# fact, and write-time enforcement is sufficient for our purposes.
- db_cols = {c["name"]: c for c in inspector.get_columns(table.name)}
+ # The Alembic-only pgvector column triggers an unknown-type warning.
+ with warnings.catch_warnings():
+ if dialect.name == "postgresql": # type: ignore[attr-defined]
+ warnings.filterwarnings("ignore", message="Did not recognize type 'vector'")
+ db_cols = {c["name"]: c for c in inspector.get_columns(table.name)}
if dialect.name == "postgresql": # type: ignore[attr-defined]
for what, statement in _loosen_postgres_columns(table, db_cols, dialect):
_run(what, lambda statement=statement: statement)
diff --git a/tests/unit/persistence/test_schema_reconciliation.py b/tests/unit/persistence/test_schema_reconciliation.py
index 7ea2f4ed1..8b7f22c91 100644
--- a/tests/unit/persistence/test_schema_reconciliation.py
+++ b/tests/unit/persistence/test_schema_reconciliation.py
@@ -574,3 +574,31 @@ async def test_adding_owner_line_pct_with_nothing_to_move_succeeds(tmp_path: Pat
await engine.dispose()
assert "primary_owner_line_pct" in _table_columns(db_path, "git_metadata")
+
+
+def test_postgres_reconcile_ignores_pgvector_type_warning(monkeypatch: pytest.MonkeyPatch) -> None:
+ import warnings
+ from types import SimpleNamespace
+
+ from sqlalchemy.exc import SAWarning
+
+ from repowise.core.persistence import database as db_module
+
+ table = Base.metadata.tables["wiki_pages"]
+
+ class Inspector:
+ def get_table_names(self) -> list[str]:
+ return ["wiki_pages"]
+
+ def get_columns(self, _name: str) -> list[dict[str, Any]]:
+ warnings.warn("Did not recognize type 'vector' of column 'embedding'", SAWarning, stacklevel=2)
+ return [{"name": c.name, "type": c.type, "nullable": c.nullable} for c in table.columns]
+
+ def get_indexes(self, _name: str) -> list[dict[str, Any]]:
+ return [{"name": i.name} for i in table.indexes]
+
+ monkeypatch.setattr(db_module, "inspect", lambda _conn: Inspector())
+ connection = SimpleNamespace(dialect=postgresql.dialect(), execute=lambda _stmt: None)
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
+ db_module._reconcile_schema(connection)